1

嗨,我从法国的一个地方下载了 drive_service 的图表,我正在尝试获取特定边缘的长度.. 有什么办法吗?

import osmnx as ox

name_place = 'Aubervilliers, France'

graph_aubervillier = ox.graph_from_address( name_place ,network_type="drive_service")


graph_aubervillier[348206084][256242027]

AtlasView({0: {'highway': 'residential', 'geometry': , 'osmid': 31297114, 'junction': 'roundabout', 'oneway': True, 'length': 26.204}})

4

1 回答 1

4

当您调用 时graph_aubervillier[348206084][256242027],您将返回这两个节点之间所有可能的边。请注意,该图是一个 MultiDiGraph,它可以在两个节点之间有多个边。

因此,如果要获取两个节点之间的所有长度,则需要遍历 AtlasView 对象:

import osmnx as ox

name_place = 'Aubervilliers, France'

graph_aubervillier = ox.graph_from_address(name_place ,network_type="drive_service")

edges_of_interest = graph_aubervillier[348206084][256242027]

for edge in edges_of_interest.values():
    # May not have a length. Return None if this is the case.
    # Could save these to a new list, or do something else with them. Up to you.
    print(edge.get('length', None))
于 2019-03-06T03:08:52.593 回答