raster_tools.general.erode#

raster_tools.general.erode(raster, size)[source]#

Perform erosion on a raster

Erosion increases the thickness of raster features. Features with higher values will cover features with lower values. At each cell, the miximum value within a window, defined by size, is stored in the output location. This is very similar to the max focal filter except that raster features are eroded (contracted) into null regions. Erosion is performed on each band separately.

Parameters
  • raster (Raster or path str) – The raster to erode

  • size (int or 2-tuple of ints) – The shape of the window to use when eroding. A Single int is interpreted as the size of a square window. A tuple of 2 ints is used as the dimensions of rectangular window. At least one value must be greater than 1. Values cannot be less than 1.

Returns

The resulting raster with eroded features. This raster will have the same shape and meta data as the original

Return type

Raster

References

1

https://en.wikipedia.org/wiki/Erosion_%28morphology%29

2

https://en.wikipedia.org/wiki/Mathematical_morphology