geopandas.GeoSeries.minimum_clearance#

GeoSeries.minimum_clearance()[source]#

Returns a Series containing the minimum clearance distance, which is the smallest distance by which a vertex of the geometry could be moved to produce an invalid geometry.

If no minimum clearance exists for a geometry (for example, a single point, or an empty geometry), infinity is returned.

Examples

>>> from shapely.geometry import Polygon, LineString, Point
>>> s = geopandas.GeoSeries(
...     [
...         Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]),
...         LineString([(0, 0), (1, 1), (3, 2)]),
...         Point(0, 0),
...     ]
... )
>>> s
0    POLYGON ((0 0, 1 1, 0 1, 0 0))
1        LINESTRING (0 0, 1 1, 3 2)
2                       POINT (0 0)
dtype: geometry
>>> s.minimum_clearance()
0    0.707107
1    1.414214
2         inf
dtype: float64