gemgis.raster.calculate_hillshades
gemgis.raster.calculate_hillshades#
- gemgis.raster.calculate_hillshades(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, azdeg: Union[int, float] = 225, altdeg: Union[int, float] = 45, band_no: int = 1) numpy.ndarray #
Calculating Hillshades 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 points representing the extent of the raster if raster is passed as array, e.g.
extent=[0, 972, 0, 1069]
azdeg (Union[int, float]) – Azimuth value for the light source direction, e.g.
azdeg=225
, default is225
degreesaltdeg (Union[int, float]) – Altitude value for the light source, e.g.
altdeg=45
, default is45
degreesband_no (int) – Band number of the raster to be used for calculating the hillshades, e.g.
band_no=1
, default is1
- Returns
hillshades – NumPy array containing the hillshade color 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 hillshades from raster >>> hillshades = gg.raster.calculate_hillshades(raster=raster) >>> hillshades array([[250.04817, 250.21147, 250.38988, ..., 235.01764, 235.0847 , 235.0842 ], ....], dtype=float32)
See also
calculate_slope
Calculating the slope of a raster
calculate_aspect
Calculating the aspect of a raster
calculate_difference
Calculating the difference between two rasters