⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂

Inheritance to geo-images and beyond#

Inheritance is practical to naturally pass down parent methods and attributes to child classes.

Many subtypes of Rasters geospatial data exist that require additional attributes and methods, yet might benefit from methods implemented in GeoUtils.

Overview of Raster inheritance#

Below is a diagram showing current Raster inheritance, which extends into other packages such as xDEM for analyzing digital elevation models.

Inheritance diagram of geoutils.raster.raster, geoutils.raster.satimg


The DEM class re-implements all methods of gdalDEM (and more) to derive topographic attributes (hillshade, slope, aspect, etc), coded directly in Python for scalability and tested to yield the exact same results. Among others, it also adds a vcrs property to consistently manage vertical referencing (ellipsoid, geoids).

If you are DEM-enthusiastic, check-out our sister package xDEM for digital elevation models.

The internal SatelliteImage subclass#

GeoUtils subclasses Rasters to SatelliteImages for remote sensing users interested in parsing metadata from space- or airborne imagery.

Based on the filename, or auxiliary files, the SatelliteImage class attempts to automatically parse a datetime, sensor, tile_name, and other information.

import geoutils as gu

# Instantiate a geo-image from an ASTER image
filename_geoimg = gu.examples.get_path("exploradores_aster_dem")
geoimg = gu.SatelliteImage(filename_geoimg, silent=False)
From filename: setting satellite as Terra
From filename: setting sensor as ASTER
From filename: setting product as L1A
From filename: setting version as 3
From filename: setting datetime as 2012-03-18 14:42:28
# Instantiate a geo-image from a Landsat 7 image
filename_geoimg2 = gu.examples.get_path("everest_landsat_b4")
geoimg2 = gu.SatelliteImage(filename_geoimg2, silent=False)
From filename: setting satellite as Landsat 7
From filename: setting sensor as ETM+
From filename: setting tile_name as 140041
From filename: setting datetime as 2000-10-30 00:00:00

Along these additional attributes, the SatelliteImage possesses the same main attributes as a Raster.

# The geo-image main attributes
  data=[[1271.3924560546875 1275.370849609375 1250.194091796875 ...
         1222.8572998046875 1220.2845458984375 1226.8214111328125]
        [1257.896484375 1259.9190673828125 1245.8509521484375 ...
         1224.7470703125 1221.00927734375 1228.203369140625]
        [1186.001953125 1160.00537109375 1154.0457763671875 ...
         1231.4954833984375 1227.606689453125 1236.4666748046875]
        [2690.725830078125 2695.724609375 2700.945556640625 ...
         1391.3909912109375 1411.371826171875 1436.488525390625]
        [2688.682373046875 2693.766845703125 2697.1826171875 ...
         1399.401123046875 1423.4818115234375 1451.060546875]
        [2686.294677734375 2692.3466796875 2694.712890625 ... 1413.9849853515625
         1437.3868408203125 1461.232177734375]]
  transform=| 30.00, 0.00, 627175.00|
            | 0.00,-30.00, 4852085.00|
            | 0.00, 0.00, 1.00|

And beyond#

Many types of geospatial data can be viewed as a subclass of Rasters, which have more attributes and require their own methods: spectral images, velocity fields, phase difference maps, etc…

If you are interested to build your own subclass of Raster, you can take example of the structure of geoutils.SatelliteImage and xdem.DEM. Then, just add any of your own attributes and methods, and overload parent methods if necessary! Don’t hesitate to reach out on our GitHub if you have a subclassing project.