本文介绍了OSMnx可视化在Folium上的边缘中心度图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码在边缘上绘制边缘中心度图

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)

其中,ec是边缘颜色的列表,但未显示. edge_color是否接受颜色列表?有什么想法吗?

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

推荐答案

我尝试将新的边缘颜色列添加到图形边缘的gdf

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

然后修改两个功能

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

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

达到最终结果:

这篇关于OSMnx可视化在Folium上的边缘中心度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 01:21