OSMnx Visualize the graph of edge centrality on Folium

跟風遠走 提交于 2020-01-04 09:47:07

问题


I'm trying to plot the graph of edge centrality on the folium using the following code

graph_map = ox.plot_graph_folium(G, popup_attribute='name', tiles='stamenterrain', edge_color=ec, edge_width=2)

where ec is list of edge colors but it is not showing up. Does edge_color accept a list of colors ? Any ideas?

I really appreciate if you can help me.

https://github.com/gboeing/osmnx-examples/blob/master/notebooks/08-example-line-graph.ipynb


回答1:


I tried adding a new column of edge color to gdf of the graph edges

gdf_edges = ox.graph_to_gdfs(G, nodes=False, fill_edge_geometry=True) gdf_edges['edge_color'] = ec

Then modify two function

make_folium_polyline(edge, edge_width, edge_opacity, popup_attribute=None)

and

plot_graph_folium(gdf_edges, graph_map=None, popup_attribute=None, tiles='cartodbpositron', zoom=1, fit_bounds=True, edge_width=5, edge_opacity=1)

The final result is achieved



来源:https://stackoverflow.com/questions/49546015/osmnx-visualize-the-graph-of-edge-centrality-on-folium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!