我一直试图将不同的 osmnx 图叠加到大叶草上,但我一直无法做到。我想用一个简单的 osmnx 图来实现与下图所示相同的事情,但在大叶上,红色边缘为红色,其他边缘为不同颜色。
fig, ax = ox.plot_graph_routes(G,max_response_edges, bgcolor='k', node_size=30, node_color='#999999', node_edgecolor='none', node_zorder=2,
edge_color='#555555', edge_linewidth=1.5, edge_alpha=1,figsize = (20,20))
我尝试使用以下代码:
H = G.copy()
H1 = G.copy()
H.remove_edges_from(G.edges - set(map(lambda x: tuple(x)+(0,),max_response_edges)))
m = ox.folium.plot_graph_folium(H,tiles='openstreetmap',popup_attribute='name',opacity = 1,color = 'red',weight= 10)
H1.remove_edges_from(set(map(lambda x: tuple(x)+(0,),max_response_edges)))
n = ox.folium.plot_graph_folium(H1,tiles='openstreetmap',popup_attribute='name',opacity = 1,color = 'blue',weight= 10)
n.add_to(m)
m
我尝试使用 m.add_child()
或 m.add_to()
,但没有一个被证明有用。发布了一个类似的堆栈溢出问题 here 但这不起作用。可以做大叶覆盖吗?
答案 0 :(得分:0)
通过以下代码让它工作
H = G.copy()
H1 = G.copy()
H.remove_edges_from(G.edges - set(map(lambda x: tuple(x)+(0,),max_response_edges)))
m = ox.folium.plot_graph_folium(H,tiles='openstreetmap',popup_attribute='name',opacity = 1,color = 'red',weight= 10)
H1.remove_edges_from(set(map(lambda x: tuple(x)+(0,),max_response_edges)))
m = ox.folium.plot_graph_folium(H1, graph_map = m,tiles='openstreetmap',popup_attribute='name',opacity = 1,color = 'blue',weight= 10)
m
结果我遗漏了 graph_map=m
参数