简体   繁体   English

如何在osmnx图中获取图中节点的经纬度点?

[英]How to get the latitude and longitude points of a node in a graph in osmnx graph?

I constructed a graph and want to see the latitude and longitude values of each node in the graph. 我构造了一个图,并希望查看图中每个节点的纬度和经度值。 How can I find those? 我如何找到那些?

I used G.nodes to find each node but I get some sort of ids. 我使用G.nodes来找到每个节点,但是我得到了某种ID。

import osmnx as ox

G = ox.graph_from_point((41.0911561, 29.0151246), distance=500)
print(G.nodes)

output : (shortened) 输出:(缩短)

[2394717187, 2394717190, 3445170185, ...

For a node with id = 2394717187, get it with this code: 对于id = 2394717187的节点,请使用以下代码获取它:

node0 = G.nodes(data=True)[2394717187]

then, you can print its long and lat with: 然后,你可以打印其longlat带:

print( node0['x'], node0['y'] )

The output will be:- 29.0119616 41.0892429 输出将是:-29.0119616 41.0892429

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM