shapely.line_locate_point#
- line_locate_point(line, other, normalized=False, **kwargs)#
Return 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
Line or lines to calculate the distance to.
- otherGeometry or array_like
Point or points to calculate the distance from.
- normalizedbool, default False
If True, the distance is a fraction of the total line length instead of the absolute distance.
- **kwargs
See NumPy ufunc docs for other keyword arguments.
Examples
>>> import shapely >>> from shapely import LineString, Point >>> line = LineString([(0, 2), (0, 10)]) >>> point = Point(4, 4) >>> shapely.line_locate_point(line, point) 2.0 >>> shapely.line_locate_point(line, point, normalized=True) 0.25 >>> shapely.line_locate_point(line, Point(0, 18)) 8.0 >>> shapely.line_locate_point(LineString(), point) nan