xrspatial.morphology.morph_erode#

xrspatial.morphology.morph_erode(agg, kernel=None, boundary='nan', name='erode')[source]#

Apply morphological erosion (local minimum) to a 2D raster.

Each output cell receives the minimum value found within the structuring element footprint centred on that cell.

Parameters:
  • agg (xarray.DataArray) – 2D raster of numeric values.

  • kernel (numpy.ndarray or None) – 2D structuring element with odd dimensions. Non-zero entries mark the footprint. Defaults to a 3x3 square (np.ones((3, 3), dtype=np.uint8)).

  • boundary (str, default 'nan') – Edge handling: 'nan', 'nearest', 'reflect', or 'wrap'.

  • name (str, default 'erode') – Name for the output DataArray.

Returns:

Eroded raster with the same shape, coords, dims, and attrs as the input.

Return type:

xarray.DataArray

Examples

>>> from xrspatial.morphology import morph_erode
>>> eroded = morph_erode(raster, kernel=np.ones((5, 5), dtype=np.uint8))