xrspatial.slope.slope#

xrspatial.slope.slope(agg: xarray.core.dataarray.DataArray, name: str = 'slope') xarray.core.dataarray.DataArray[source]#

Returns slope of input aggregate in degrees.

Parameters
  • agg (xr.DataArray) – 2D array of elevation data.

  • name (str, default='slope') – Name of output DataArray.

Returns

slope_agg – 2D array of slope values. All other input attributes are preserved.

Return type

xr.DataArray of same type as agg

References

Examples

>>> import numpy as np
>>> import xarray as xr
>>> from xrspatial import slope
>>> data = np.array([
...     [0, 0, 0, 0, 0],
...     [0, 0, 0, -1, 2],
...     [0, 0, 0, 0, 1],
...     [0, 0, 0, 5, 0]])
>>> agg = xr.DataArray(data)
>>> slope_agg = slope(agg)
>>> slope_agg
<xarray.DataArray 'slope' (dim_0: 4, dim_1: 5)>
array([[      nan,       nan,       nan,       nan,       nan],
       [      nan,  0.      , 14.036243, 32.512516,       nan],
       [      nan,  0.      , 42.031113, 53.395725,       nan],
       [      nan,       nan,       nan,       nan,       nan]],
      dtype=float32)
Dimensions without coordinates: dim_0, dim_1