【发布时间】:2021-04-17 09:52:35
【问题描述】:
我正在尝试绘制多条路线,但弹出错误 - networkx.exception.NetworkXError:nbunch 序列中的节点 [20461931, 75901933] 不是有效节点。
绘制单个路线不再是问题,但绘制在一起时会引发错误。
import networkx as nx
import osmnx as ox
# Create Graph
G = ox.graph_from_place('Munich, Germany', network_type='drive')
# route1 calc
origin_node = 20461931
destination_node = 75901933
route1 = nx.shortest_path(G, origin_node, destination_node)
# route2 calc
start = (48.1336081, 11.58172095)
end = (48.17822992, 11.53754219)
start_node = ox.get_nearest_node(G, start)
end_node = ox.get_nearest_node(G, end)
route2 = nx.shortest_path(G, start_node, end_node, weight='travel_time')
#plot the route with folium
route_list = [route1,route2]
route_map = ox.plot_route_folium(G,route_list)
# save as html file then display map as an iframe
filepath = 'route.html'
route_map.save(filepath)
【问题讨论】: