引用https://github.com/Toblerity/Shapely/issues/190

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.

end = Point(19.125150,72.893218)
np = Point(19.12493833590478, 72.89314854771877)
expected = Point(19.124929, 72.893177) print end.distance(np) # 0.000222767386696
print end.distance(expected) # 0.000224770994572

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):

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.

直线上距离最近的点,不等于定义时用的vertix

而要得到最近的vertix,关键的思路是把Linestring“退化“成vertix的MultiPoint,退化回"点对点"距离问题,就OK了。

the nearest point/vertex point of linestring的更多相关文章

  1. Codeforces Round #382 (Div. 2)E. Ostap and Tree

    E. Ostap and Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  2. ●洛谷P3233 [HNOI2014]世界树

    题链: https://www.luogu.org/problemnew/show/P3233题解: 虚树,dp,倍增. 首先对于每个询问,要把虚树建出来,这一步就从略了.这里着重分享一下如何求答案. ...

  3. Codeforces 735 E Ostap and Tree

    Discription Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his ga ...

  4. Shader Model 3.0:Using Vertex Textures SM3:使用顶点纹理 (NVIDIA spec, 6800支持使用D3DFMT_R32F and D3DFMT_A32B32G32R32F的纹理格式实现Vertex Texture。)

    翻译者 周波 zhoubo22@hotmail.com 版权所有 Philipp Gerasimov Randima (Randy) Fernando Simon Green NVIDIA Corpo ...

  5. Using Vertex Texture Displacement for Realistic Water Rendering

    http://blog.csdn.net/soilwork/article/details/709869 Using Vertex Texture Displacement for Realistic ...

  6. Nearest neighbor graph | 近邻图

    最近在开发一套自己的单细胞分析方法,所以copy paste事业有所停顿. 实例: R eNetIt v0.1-1 data(ralu.site) # Saturated spatial graph ...

  7. Codeforces1110F Nearest Leaf dfs + 线段树 + 询问离线

    Codeforces1110F dfs + 线段树 + 询问离线 F. Nearest Leaf Description: Let's define the Eulerian traversal of ...

  8. CSharpGL(38)带初始数据创建Vertex Buffer Object的情形汇总

    CSharpGL(38)带初始数据创建Vertex Buffer Object的情形汇总 开始 总的来说,OpenGL应用开发者会遇到为如下三种数据创建Vertex Buffer Object的情形: ...

  9. OpenGL中glVertex、显示列表(glCallList)、顶点数组(Vertex array)、VBO及VAO区别

    OpenGL中glVertex.显示列表(glCallList).顶点数组(Vertex array).VBO及VAO区别 1.glVertex 最原始的设置顶点方法,在glBegin和glEnd之间 ...

随机推荐

  1. GC垃圾回收理解

    内存的计算 -Xms1G -Xmx2G -Xmn500M -XX:MaxPermSize=64M -XX:+UseConcMarkSweepGC -XX:SurvivorRatio=3, 请问eden ...

  2. priority_queue member function

    没有优先队列的dijkstra不算真的dijkstra 所以我又回来补常识了 <1>priority_queue::emplace <7>priority_queue::top ...

  3. 版本控制器之SVN(二)

    安装重启以后,在菜单栏找到TortoiseSVN程序 启动以后 点击: 填写相应的信息: 可以看到项目的相关信息 选中仓库,右键 > Browse Repository 进入如下界面: 可以打开 ...

  4. Linux-1.5日志查看常用命令

    常访问的日志目录:\data\log\(message系统 | secure安全 | maillog邮件) 进入日志目录 find \d1\data\log -name '*log' 在目录下查找以l ...

  5. Mysql8 root密码忘记了

    需要确定自己的mysql版本是否是8 [root@smonitor ~]# mysql --version mysql Ver 8.0.13 for Linux on x86_64 (MySQL Co ...

  6. 牛客 2B 树 (组合计数)

    传送门 大意: 给定n节点树, 求划分为不超过$k$个连通块的方案数. n,k<=300. 核心观察是每个连通块深度最低的点固定以后染色方案就固定了. 所以答案为$\sum\limits_{i= ...

  7. bagging and boosting

    bagging 侧重于降低方差 方差-variance 方差描述的是预测值的变化范围,离散程度,也就是离期真实值的距离.方差过大表现为过拟合,训练数据的预测f-score很高,但是验证或测试数据的预测 ...

  8. window.location.href 与 window.location.href 的区别

  9. 解决GitHub添加sshkey仍然无法访问clone远程仓库的问题

    1 ssh -v git@github.com 通过这个命令打印调试信息 ebug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS rece ...

  10. 【LOJ 6695】天气之子

    找规律题的典范? OEIS裸题 考场上让你用 OEIS 吗 题意 link 题解 \(n\le 5\) 打表 \(n\le 10^5\) 发现不能直接求最优解,于是二分答案. 验证答案时,先把前 \( ...