shapely.shortest_line#
- shortest_line(a, b, **kwargs)#
Return the shortest line between two geometries.
The resulting line consists of two points, representing the nearest points between the geometry pair. The line always starts in the first geometry a and ends in the second geometry b. The endpoints of the line will not necessarily be existing vertices of the input geometries a and b, but can also be a point along a line segment.
- Parameters:
- a, bGeometry or array_like
Geometry or geometries to compare.
- **kwargs
See NumPy ufunc docs for other keyword arguments.
See also
prepareimprove performance by preparing
a(the first argument)
Examples
>>> import shapely >>> from shapely import LineString >>> line1 = LineString([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]) >>> line2 = LineString([(0, 3), (3, 0), (5, 3)]) >>> shapely.shortest_line(line1, line2) <LINESTRING (1 1, 1.5 1.5)>