引用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. Elasticsearch集群基本操作

    检查集群的命令 $ curl http://172.16.101.55:9200/_cat =^.^= /_cat/allocation /_cat/shards /_cat/shards/{inde ...

  2. Linux学习笔记(15)Linux字符集(locale,LANG,LC_ALL)

    关键词:linux系统修改编码,linux字符集问题, 目录  零.什么是locale 一.locale的详细内容 二.理解locale的设置 三 具体设定locale的方法(zh_CN.UTF-8. ...

  3. 【图论好题】ABC #142 Task F Pure

    题目大意 给定一个 $N$ 个点 $M$ 条边的有向图 $G$,无重边.自环.找出图 $G$ 的一个导出子图(induced subgraph) $G'$,且 $G'$ 中的每个点的入度和出度都是 1 ...

  4. Git_基础命令

    gitinit//初始化一个Git仓库" role="presentation">gitinit//初始化一个Git仓库gitinit//初始化一个Git仓库 gi ...

  5. 继续:Ruby on Rails 简单了解

    一. 接着上一篇继续 1.限制微博的长度 在 Rails 中实现这种限制很简单,使用验证(validation)功能即可.要限制微博的长度最多为 140 个字符 (1).打开文件:app/models ...

  6. Souvenirs CodeForces - 765F (好题)

    大意: 给定序列$a$, $m$个询问$[l,r]$, 回答$[l,r]$内最接近的两个数的差. 考虑离线, 枚举右端点, 每个点维护左端点的贡献, 对于新添一个点$a_r$, 只考虑左侧点比$a_r ...

  7. redis 学习(15)-- GEO

    GEO GEO 简介 Redis 3.2添加新特性 功能:存储经纬度.计算两地距离.范围计算等 基于ZSet实现 删除操作使用 zrem key member GEO 相关命令 1.geoadd ke ...

  8. Abp添加新的接口(扩展底层接口)

    在https://aspnetboilerplate.com/Templates 创建项目之后,下载用Vs2019打开(vs2017不支持netcore3.0)结构如下: 一. 2. 在xx.core ...

  9. docker 环境安装

    centos7下安装docker.docker-compose 参考文档:https://docs.docker.com/ 一.安装docker 1).Docker 要求 CentOS 系统的内核版本 ...

  10. shell中字符串操作【转】

    转自:http://blog.chinaunix.net/uid-29091195-id-3974751.html 我们所遇到的编程语言中(汇编除外)都少不了字符串处理函数吧,当然shell编程也不例 ...