License Information

Use of this function requires a license for Whitebox Workflows for Python Professional (WbW-Pro). Please visit www.whiteboxgeo.com to purchase a license.

Description

This tool can be used to remove holes in raster polygons. Holes are areas of background values (either zero or NoData), completely surrounded by foreground values (any value other than zero or NoData). Therefore, this tool can somewhat be considered to be the raster equivalent to the vector-based RemovePolygonHoles tool. Users may optionally remove holes less than a specified threshold size (--threshold), measured in grid cells. Hole size is determined using a clumping operation, similar to what is used by the Clump tool. Users may also optionally specify whether or not to included 8-cell diagonal connectedness during the clumping operation (--use_diagonals).

Some GIS professionals have previously used a closing operation to lessen the extent of polygon holes in raster data. A closing is a mathematical morphology operation that involves expanding the raster polygons using a dialation filter (MaximumFilter), followed by a dialation filter (MinimumFilter) on the resulting image. While this common image processing technique can be helpful for reducing the prevalance of polygon holes, it can also have considerable impact on non-hole features within the image. The RemoveRasterPolygonHoles tool, by comparison, will only affect hole features and does not impact the boundaries of other polygons at all. The following image compares the removal of polygon holes (islands in a lake polygon) using a closing operation (middle) calculated using an 11x11 convolution filter and the output of the RemoveRasterPolygonHoles tool. Notice how the convolution operation impacts the edges of the polygon, particularly in convex regions, compared with the RemoveRasterPolygonHoles.

Here is a video that demonstrates how to apply this tool to a classified Sentinel-2 multi-spectral satellite imagery data set.

See Also

closing, remove_polygon_holes, clump, generalize_classified_raster

Function Signature

def remove_raster_polygon_holes(self, input: Raster, threshold_size: int = sys.maxsize, use_diagonals: bool = False) -> Raster: ...

Project Links

WbW Homepage User Manual Support WbW