I am currently working on a dataset with German postal codes. I aim to calculate "real" distances between the centers of each postal code area. To do so, I first downloaded the germany-latest.osm.bz2 file from geofabrik. Next I would like to create a graph from the downloaded file for the network_type = "driving".
However, I noticed that using the osmnx.graph.graph_from_xml() method is very time consuming for a large OMS file such as for Germany.
My questions are:
- How can I create the graph more efficiently?
- Once the graph has been created: how can I compute the "real" distances for a large set of origin-destination-pairs?
Thank you!
I am attaching my current code for reference:
import os
from pyrosm import OSM, get_data
import osmnx as ox
import networkx as nx
os.chdir(r"myPath")
xml = "germany-latest.osm.bz2"
graph = ox.graph.graph_from_xml(xml) #how to restrict to network_type = "driving"?