如何在边缘之间获得两个节点(坐标)?在OSMNX中,如果我有(u,v,x)by ox.distance.nearest_edges
我有一个边缘的ID,我想获得其中节点的坐标(x,y),我尝试这样的方法:
#this is my graph:
G = ox.graph_from_address('Arequipa, Arequipa', `network_type='drive',simplify=True,dist=7000)
#where nearestEdge[x][0] = u, nearesEdge[x][1] = v
coordinates_edges = G.edges[nearestEdge[0][0], nearestEdge[0][1],0]
print(coordinates_edges)
输出:
{'osmid': 571036931, 'highway': 'residential', 'oneway': False, 'length': 55.707}
如果我尝试:
coordinates_edges = G.edges[nearestEdge[0][0], nearestEdge[0][1],0]['geometry']
我得到此错误:
KeyError Traceback (most recent call last)
<ipython-input-52-20f93c142504> in <module>()
8 #coordinates_nodes = G.nodes[5517424179]['y']
9
---> 10 coordinates_edges = G.edges[nearestEdge[0][0], nearestEdge[0][1],0]['geometry']
11 print(coordinates_edges)
12
KeyError: 'geometry'
I have the id's of an edge and I want to get the coordinates(x,y) of the nodes inside it, I try this way:
#this is my graph:
G = ox.graph_from_address('Arequipa, Arequipa', `network_type='drive',simplify=True,dist=7000)
#where nearestEdge[x][0] = u, nearesEdge[x][1] = v
coordinates_edges = G.edges[nearestEdge[0][0], nearestEdge[0][1],0]
print(coordinates_edges)
Output:
{'osmid': 571036931, 'highway': 'residential', 'oneway': False, 'length': 55.707}
if I try:
coordinates_edges = G.edges[nearestEdge[0][0], nearestEdge[0][1],0]['geometry']
I get this error:
KeyError Traceback (most recent call last)
<ipython-input-52-20f93c142504> in <module>()
8 #coordinates_nodes = G.nodes[5517424179]['y']
9
---> 10 coordinates_edges = G.edges[nearestEdge[0][0], nearestEdge[0][1],0]['geometry']
11 print(coordinates_edges)
12
KeyError: 'geometry'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我并不完全清楚您的意思:
如果您问如何获得边缘连接的两个节点的坐标,则可以执行类似:
通过OSMNX 文档和networkx documentation 以熟悉这样的基本功能。
I'm not totally clear what you mean by:
If you're asking how do you get the coordinates of the two nodes that an edge connects, you can do something like:
Read through the OSMnx documentation and the NetworkX documentation to familiarize yourself with basic functionality like this.