gemgis.raster.calculate_difference#

gemgis.raster.calculate_difference(raster1: Union[numpy.ndarray, rasterio.io.DatasetReader], raster2: Union[numpy.ndarray, rasterio.io.DatasetReader], flip_array: bool = False) numpy.ndarray#

Calculating the difference between two rasters

Parameters
  • raster1 (np.ndarray) – First array

  • raster2 (np.ndarray) – Second array

  • flip_array (bool) – Variable to flip the array. Options include: True or False, default set to False

Returns

array_diff – Array containing the difference between array1 and array2

Return type

np.ndarray

New in version 1.0.x.

Example

>>> # Loading Libraries and Files
>>> import gemgis as gg
>>> import rasterio
>>> raster1 = rasterio.open(fp='raster1.tif')
>>> raster2 = rasterio.open(fp='raster2.tif')
>>> # Calculate difference between two rasters
>>> difference = gg.raster.calculate_difference(raster1=raster1, raster2=raster2)
>>> difference
array([[-10., -10., -10., ..., -10., -10., -10.],.....], dtype=float32)

See also

calculate_hillshades

Calculating the hillshades of a raster

calculate_slope

Calculating the slope of a raster

calculate_aspect

Calculating the aspect of a raster