xrspatial.morphology.morph_gradient#
- xrspatial.morphology.morph_gradient(agg, kernel=None, boundary='nan', name='gradient')[source]#
Morphological gradient: dilation minus erosion.
Highlights edges and transitions in a 2D raster. The result is always non-negative for non-NaN cells.
- Parameters:
agg (xarray.DataArray) – 2D raster of numeric values.
kernel (numpy.ndarray or None) – 2D structuring element with odd dimensions. Defaults to a 3x3 square.
boundary (str, default
'nan') – Edge handling:'nan','nearest','reflect', or'wrap'.name (str, default
'gradient') – Name for the output DataArray.
- Returns:
Gradient raster (dilate - erode).
- Return type:
xarray.DataArray
Examples
>>> from xrspatial.morphology import morph_gradient >>> edges = morph_gradient(elevation)