gemgis.raster.calculate_slope#

gemgis.raster.calculate_slope(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, band_no: int = 1) numpy.ndarray#

Calculating the slope based on digital elevation model/raster

Parameters
  • raster (np.ndarray, rasterio.io.DatasetReader) – NumPy array or rasterio object containing the elevation data

  • extent (List[Union[int, float]]) – List of minx, maxx, miny and maxy coordinates representing the raster extent if raster is passed as array, e.g. extent=[0, 972, 0, 1069]

  • band_no (int) – Band number of the raster to be used for calculating the hillshades, e.g. band_no=1, default is 1

Returns

slope – NumPy array containing the slope values

Return type

np.ndarray

New in version 1.0.x.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import rasterio
>>> raster = rasterio.open(fp='raster.tif')
>>> # Calculating the slope of a raster
>>> slope = gg.raster.calculate_slope(raster=raster)
>>> slope
array([[37.092472, 36.95191 , 36.649662, ..., 21.988844, 22.367924,
22.584248],....], dtype=float32)

See also

calculate_hillshades

Calculating the hillshades of a raster

calculate_aspect

Calculating the aspect of a raster

calculate_difference

Calculating the difference between two rasters