shapely.minimum_clearance

shapely.minimum_clearance#

minimum_clearance(geometry, **kwargs)#

Computes the Minimum Clearance distance.

Note

‘minimum_clearance’ requires at least GEOS 3.6.0.

A geometry’s “minimum clearance” 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.

Parameters:
geometryGeometry or array_like
**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> from shapely import Polygon
>>> polygon = Polygon([(0, 0), (0, 10), (5, 6), (10, 10), (10, 0), (5, 4), (0, 0)])
>>> minimum_clearance(polygon)
2.0
>>> minimum_clearance(Polygon())
inf
>>> minimum_clearance(None)
nan