CharlesAntoine
CharlesAntoine

Reputation: 83

Python - Osmnx - Use cache or local maps to reduce computation time

I have a dataframe composed of different trips, categorised by the type of trip (e.g. by car or by bike). Each line of the dataframe represents a stop of a given trip, including the sequence of the stop in the trip as well as its latitude/longitude coordinates.

After some search on how to plot those trips, i discovered the osmnx package. The streets network is awesome but takes a long time to be generated, especially for large zones.

Is there a way to increase computation performance, for instance downloading in local the network of the region or any other way?

Thank you for your help

import osmnx as ox
import matplotlib.pyplot as plt

place_name='France'
graph=ox.graph_from_place(place_name)  
type(graph)

nodes, edges = ox.graph_to_gdfs(graph)   
nodes.head()
edges.head()
type(edges)

fig, ax = plt.subplots(figsize=(15,15)) 
edges.plot(ax=ax, linewidth=1, edgecolor='#BC8F8F')

Upvotes: 2

Views: 2214

Answers (1)

gboeing
gboeing

Reputation: 6442

If you want to download a network for an entire country like Switzerland or France, you will need an enormous amount of RAM to store it in memory. You may want to filter to retain only certain road types. See also https://stackoverflow.com/a/52412274/7321942

In addition, you should turn caching on with ox.config(use_cache=True, log_console=True). See the documentation for details. You should also turn logging on to see what's happening under the hood if you're wondering why it's taking so long.

Upvotes: 3

Related Questions