Cleaning geometries¶
- coverage_clean(gdf, tolerance, mask=None, snap_to_anchors=True, **kwargs)[source]¶
Fix thin gaps, holes, slivers and double surfaces.
The operations might raise GEOSExceptions, so it might be nessecary to set the ‘grid_sizes’ argument, it might also be a good idea to run coverage_clean twice to fill gaps resulting from these GEOSExceptions.
Rules: - Holes (interiors) thinner than the tolerance are closed. - Gaps between polygons are filled if thinner than the tolerance. - Sliver polygons thinner than the tolerance are eliminated into the neighbor polygon with the longest shared border. - Double surfaces thinner than the tolerance are eliminated. If duplicate_action is “fix”, thicker double surfaces will be updated. - Line and point geometries are removed with no warning. - MultiPolygons and GeometryCollections are exploded to Polygons. - Index is reset.
- Parameters:
gdf (
GeoDataFrame
) – GeoDataFrame to be cleaned.tolerance (
int
|float
) – distance (usually meters) used as the minimum thickness for polygons to be eliminated. Any gap, hole, sliver or double surface that are empty after a negative buffer of tolerance / 2 are eliminated into the neighbor with the longest shared border.mask (
GeoDataFrame
|GeoSeries
|Geometry
|None
) – Mask to clip gdf to.snap_to_anchors (
bool
) – If True (default), snaps to anchor nodes in gdf. If False, only snaps to mask nodes (mask cannot be None in this case).**kwargs – Temporary backwards compatibility to avoid TypeErrors.
- Return type:
GeoDataFrame
- Returns:
A GeoDataFrame with cleaned polygons.