geopandas.GeoSeries.is_valid_coverage#

GeoSeries.is_valid_coverage(*, gap_width=0.0)[source]#

Returns a bool indicating whether a GeoSeries forms a valid coverage

A GeoSeries of valid polygons is considered a coverage if the polygons are:

  • Non-overlapping - polygons do not overlap (their interiors do not intersect)

  • Edge-Matched - vertices along shared edges are identical

A valid coverage may contain holes (regions of no coverage). However, sometimes it might be desirable to detect narrow gaps as invalidities in the coverage. The gap_width parameter allows to specify the maximum width of gaps to detect. When gaps are detected, this method will return False and the coverage_invalid_edges() method can be used to find the edges of those gaps.

Geometries that are not Polygon or MultiPolygon are ignored and an empty LineString is returned.

Requires Shapely >= 2.1.

Added in version 1.1.0.

Parameters:
gap_widthfloat, optional

The maximum width of gaps to detect, by default 0.0

Returns:
bool

Examples

>>> from shapely import Polygon
>>> s = geopandas.GeoSeries(
...     [
...         Polygon([(0, 0), (1, 1), (1, 0), (0, 0)]),
...         Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]),
...     ]
... )
>>> s
0    POLYGON ((0 0, 1 1, 1 0, 0 0))
1    POLYGON ((0 0, 1 1, 0 1, 0 0))
dtype: geometry
>>> s.is_valid_coverage()
True

Violation of edge-matching:

>>> s2 = geopandas.GeoSeries(
...     [
...         Polygon([(0, 0), (1, 1), (1, 0), (0, 0)]),
...         Polygon([(0, 0), (0.5, 0.5), (1, 1), (0, 1), (0, 0)])
...     ]
... )
>>> s2
0             POLYGON ((0 0, 1 1, 1 0, 0 0))
1    POLYGON ((0 0, 0.5 0.5, 1 1, 0 1, 0 0))
dtype: geometry
>>> s2.is_valid_coverage()
False