shapely.distance

Contents

shapely.distance#

distance(a, b, **kwargs)#

Compute the Cartesian distance between two geometries.

Parameters:
a, bGeometry or array_like

Geometry or geometries to compute the distance between.

**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

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