【问题标题】:How to get the latitude and longitude points of a node in a graph in osmnx graph?如何获取osmnx图中某个节点的经纬度点?
【发布时间】:2019-12-31 13:07:42
【问题描述】:

我构建了一个图表,想查看图表中每个节点的纬度和经度值。我怎样才能找到这些?

我使用G.nodes 来查找每个节点,但我得到了某种 id。

import osmnx as ox

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

输出:(缩短)

[2394717187, 2394717190, 3445170185, ...

【问题讨论】:

    标签: python graph networkx polyline osmnx


    【解决方案1】:

    对于 id = 2394717187 的节点,使用以下代码获取:

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

    然后,您可以使用以下命令打印其longlat

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

    输出将是:- 29.0119616 41.0892429

    【讨论】:

    • 在这种情况下data=True 可以被删除而不影响输出。
    猜你喜欢
    • 2017-12-03
    • 2018-11-27
    • 2019-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    相关资源
    最近更新 更多