xrspatial.morphology.morph_closing#
- xrspatial.morphology.morph_closing(agg, kernel=None, boundary='nan', name='closing')[source]#
Apply morphological closing (dilation then erosion) to a 2D raster.
Closing fills small dark gaps and pepper noise while preserving the overall shape of larger structures.
- 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
'closing') – Name for the output DataArray.
- Returns:
Closed raster.
- Return type:
xarray.DataArray
Examples
>>> from xrspatial.morphology import morph_closing >>> filled = morph_closing(binary_mask)