gboeing / osmnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
https://osmnx.readthedocs.io
MIT License
4.84k stars 821 forks source link

Question about interactively plotting large networks #136

Closed mohammad7t closed 6 years ago

mohammad7t commented 6 years ago

Hi, Thanks for the great library. Is it feasible to plot a network with large amounts of nodes and edges using osmnx? https://github.com/gboeing/osmnx/blob/5c267dcd0dc294232d6b526bd14b2d5e034ae9ee/osmnx/plot.py#L647

gboeing commented 6 years ago

@mhsekhavat yes. That's from the docstring for making folium/leaflet web maps, and as the rest of it states:

Note that anything larger than a small city can take a long time to plot and create a large web map file that is very slow to load as JavaScript.

Writing out all that data can be slow, and having your web browser render it as an interactive web map can be slow.

If you want to plot a large network, just use the standard ox.plot_graph function and it will work just fine.

mohammad7t commented 6 years ago

Thanks for your answer @gboeing . Actually, I forgot to mention "interactive" in my question. I wonder if it could be possible to plot large networks interactively. It seems that mapbox interactive maps can visualize large geojson data very well in browser, without need for external tileserver or other efforts. Example: http://bl.ocks.org/ryanbaumann/04c442906638e27db9da243f29195592

gboeing commented 6 years ago

@mhsekhavat ah, yes of course. If I were trying to plot a large network using that Mapbox GL JS method, I'd dump the graph to geopandas GeoDataFrames: https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.save_load.graph_to_gdfs

Then you can just save those GeoDataFrames to disk as GeoJSON, then plug that data into the example you linked to.

mohammad7t commented 6 years ago

Thanks