shapely.line_locate_point#

line_locate_point(line, other, normalized=False, **kwargs)#

Returns the distance to the line origin of given point.

If given point does not intersect with the line, the point will first be projected onto the line after which the distance is taken.

Parameters
lineGeometry or array_like
pointGeometry or array_like
normalizedbool, default False

If True, the distance is a fraction of the total line length instead of the absolute distance.

**kwargs

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

Examples

>>> from shapely import LineString, Point
>>> line = LineString([(0, 2), (0, 10)])
>>> point = Point(4, 4)
>>> line_locate_point(line, point)
2.0
>>> line_locate_point(line, point, normalized=True)
0.25
>>> line_locate_point(line, Point(0, 18))
8.0
>>> line_locate_point(LineString(), point)
nan