The point returned is the nearest point on the line to the original point. The nearest point is not necessarily an existing vertex in the LineString, and in this case it isn't.git
If you want to find the nearest vertex you should first convert the LineString to a MultiPoint geometry, then use the nearest_points operation (note the minor floating point error):github
from shapely.ops import nearest_points
from shapely.geometry import MultiPoint
mp = MultiPoint(route)
print nearest_points(mp, end)[0] # POINT (19.124929 72.89317699999999)
This query requires calculating the distance between the original point and each vertex in the original linestring. markdown
snorfalorpagus commented on 18 Oct 2014
The point returned is the nearest point on the line to the original point. The nearest point is not necessarily an existing vertex in the LineString, and in this case it isn't.git
If you want to find the nearest vertex you should first convert the LineString to a MultiPoint geometry, then use the
nearest_points
operation (note the minor floating point error):githubThis query requires calculating the distance between the original point and each vertex in the original linestring. markdown
直線上距離最近的點,不等於定義時用的vertixide
而要獲得最近的vertix,關鍵的思路是把Linestring「退化「成vertix的MultiPoint,退化回"點對點"距離問題,就OK了。ui