如何从最短路径/路线检索边缘

时间:2019-08-28 16:37:53

标签: python networkx osmnx

我正在使用OSMnx以便对道路基础设施进行网络分析。一旦获得相关图,我将使用最短路径算法来评估网络中两个选定节点之间的最短路径。

我想获得此路径/部分路径所交叉的边缘和相关属性,特别是我需要了解高速公路属性(道路类型),长度,最大速度。

为了获得这些详细信息,我使用了以下功能:

ox.get_route_edge_attributes(graph_proj, route, attribute='highway', minimize_key='length', retrieve_default=None)

但是我只能获取edges属性,而不是像获取节点那样获得具有与路径边缘相关的所有信息的数据框。

# Calculate the shortest path
route = nx.shortest_path(G=graph_proj, source=orig_node, target=target_node, weight='length')

# Get the nodes along the shortest path
route_nodes = nodes_proj.loc[route]

osmid_route_edges = ox.get_route_edge_attributes(graph_proj, route,attribute='osmid', minimize_key='length', retrieve_default=None)

route_edges = edges_proj.loc[osmid_route_edges]

但是我得到:

KeyError: "None of [Int64Index([ 73659661,  73659661, 501506412, 239593190,  85770573, 501506411,\n            501506411, 501506411,  85770585,  85770650,  85770523,  85770619,\n             85770619, 150945369, 150945366,   5030995,   5030995, 150950582,\n            150950583, 150950583,  30189470, 501281220,  30189471,  30189471,\n             30189471, 619451547, 619451546, 619451546, 150988548, 150988543,\n            150988543,   5030994,   5030994,  96753355, 380893167,  96753364,\n             79499553, 151082156, 151082152,  79499620, 619447279, 380893168,\n             79499557, 380893166, 151145341, 151145342, 230479624,   5030997,\n              5030997, 230479622, 143161844,  24005234,  24005234,  24005234,\n             24005234,  24005234, 143161844,  28039199, 179051291, 447745319,\n             60706445,  79499582,  60706435,  60706435,  60706435, 182461182,\n            196844227, 196844227, 557529594, 557529588, 557529588,  79499597,\n            196838777, 195575821, 447745333, 447745332, 447745334, 447745335],\n           dtype='int64')] are in the [index]"

是否存在函数或命令例程来获取具有计算出的最短路径的边缘和相关属性的数据框?

提前谢谢

0 个答案:

没有答案