shapely.distance

Contents

shapely.distance#

distance(a, b, **kwargs)#

Computes the Cartesian distance between two geometries.

Parameters:
a, bGeometry or array_like
**kwargs

See NumPy ufunc docs for other keyword arguments.

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