0

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

enter image description here

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

sentence
  • 8,213
  • 4
  • 31
  • 40
Duc Vu
  • 59
  • 1
  • 6
  • Can you provide a fuller example (see [mcve]). What is the module `ox`? – Joel Mar 29 '18 at 00:38
  • I try the example from this notebook https://github.com/gboeing/osmnx-examples/blob/master/notebooks/08-example-line-graph.ipynb @Joel – Duc Vu Mar 29 '18 at 03:10
  • It appears to me that `plot_graph_folium` may not allow a list of colors, but rather only a single color string (I haven't found anything definitive, but it looks that way). Is it feasible to do a separate plotting command for each color? – Joel Mar 29 '18 at 04:01
  • Yes, you can do this with OSMnx. See answer here: https://stackoverflow.com/a/67115678/7321942 – gboeing Apr 15 '21 at 22:22
  • Your links are now dead so I can't follow any of this Q&A. Please make your question self-contained – roganjosh May 19 '21 at 10:39

1 Answers1

0

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:

enter image description here

sentence
  • 8,213
  • 4
  • 31
  • 40
Duc Vu
  • 59
  • 1
  • 6