shapely.distance#

distance(a, b, **kwargs)#

Computes the Cartesian distance between two geometries.

Parameters
a, bGeometry or array_like
**kwargs

For other keyword-only arguments, see the NumPy ufunc docs.

Examples

>>> from shapely import LineString, Point, Polygon
>>> point = Point(0, 0)
>>> distance(Point(10, 0), point)
10.0
>>> distance(LineString([(1, 1), (1, -1)]), point)
1.0
>>> distance(Polygon([(3, 0), (5, 0), (5, 5), (3, 5), (3, 0)]), point)
3.0
>>> distance(Point(), point)
nan
>>> distance(None, point)
nan