slope#
- slope(ds: str | ~cloudpathlib.cloudpath.CloudPath | ~pathlib.Path | tuple[~numpy.ndarray | ~numpy.ma.MaskedArray, dict] | ~xarray.core.dataarray.DataArray | ~xarray.core.dataset.Dataset | ~rasterio.io.DatasetReader | ~rasterio.io.DatasetWriter, in_pct: bool = False, in_rad: bool = False) -> (<class 'numpy.ma.MaskedArray'>, <class 'dict'>)[source]#
Compute the slope of a DEM (in degrees).
Goal: replace gdaldem CLI
Warning
It uses a 2nd order gradient instead of Horn’s or Zevenbergen & Thorne’s formula
z_factor is fixed to 1.0
scale managed by ds resolution
- Args:
ds (AnyRasterType): Path to the raster, its dataset, its
xarray
or a tuple containing its array and metadata in_pct (bool): Outputs slope in percents in_rad (bool): Outputs slope in radians. Not taken into account ifin_pct == True
- Returns:
(np.ma.masked_array, dict): Slope and its metadata