首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >沿最近边获取最近节点

沿最近边获取最近节点
EN

Stack Overflow用户
提问于 2020-09-16 10:14:50
回答 2查看 127关注 0票数 0

我在这篇文章中使用了osmnx Docker镜像并遵循了gboeing的回复,但是我得到了错误AttributeError: module 'osmnx' has no attribute 'great_circle_vec'

Docker似乎有最新的0.16 osmnx版本,当前的文档没有提到这个函数被弃用或私有。建议的代码是一年半以前的代码,所以可能有什么地方发生了变化。有没有人有当前的解决方案来沿着最近的边获得最近的节点?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-09-16 10:40:21

票数 0
EN

Stack Overflow用户

发布于 2020-09-17 07:27:27

如果有人感兴趣,我可以根据最初的github问题编写一些代码,在最近的边缘上获得最近的lat/lng。它看起来像这样:

代码语言:javascript
运行
复制
def nearest_point_on_edge(G, lat, lng, edge):
    ''' Return nearest point to lat/lng on edge 
    '''
    orig_point = Point(lng, lat)
    a_point = Point(G.nodes[edge[0]]['x'], G.nodes[edge[0]]['y'])
    b_point = Point(G.nodes[edge[1]]['x'], G.nodes[edge[1]]['y'])
    a_latlng = (G.nodes[edge[0]]['y'], G.nodes[edge[0]]['x'])
    b_latlng = (G.nodes[edge[1]]['y'], G.nodes[edge[1]]['x'])
    dist_ab = LineString([a_point, b_point]).project(orig_point)
    projected_orig_point = list(LineString([a_point, b_point]).interpolate(dist_ab).coords)
    nearest_latlng = (projected_orig_point[0][1], projected_orig_point[0][0])
    return nearest_latlng
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63912189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档