我在这篇文章中使用了osmnx Docker镜像并遵循了gboeing的回复,但是我得到了错误AttributeError: module 'osmnx' has no attribute 'great_circle_vec'
Docker似乎有最新的0.16 osmnx版本,当前的文档没有提到这个函数被弃用或私有。建议的代码是一年半以前的代码,所以可能有什么地方发生了变化。有没有人有当前的解决方案来沿着最近的边获得最近的节点?
发布于 2020-09-16 02:40:21
使用osmnx.distance.great_circle_vec(args)
https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.distance.great_circle_vec
发布于 2020-09-16 23:27:27
如果有人感兴趣,我可以根据最初的github问题编写一些代码,在最近的边缘上获得最近的lat/lng。它看起来像这样:
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
https://stackoverflow.com/questions/63912189
复制相似问题