gpt4 book ai didi

python - OSMnx 可视化 Folium 上的边中心性图

转载 作者:太空宇宙 更新时间:2023-11-04 04:46:07 26 4
gpt4 key购买 nike

我正在尝试使用以下代码在叶片上绘制边中心性图

enter image description here

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

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

如果您能帮助我,我将不胜感激。

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

最佳答案

我尝试向图形边缘的 gdf ​​添加一个新的边缘颜色列

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)

最终结果实现:

enter image description here

关于python - OSMnx 可视化 Folium 上的边中心性图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49546015/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com