Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with large maps in osmnx

What is the best way to calculate the shortest street distance between two locations which cover a large distance using OSmnx. For example, if I was trying to find a route across the US?

Doing this seems burdensome, and perhaps impossible given my compute resources.

G = ox.graph_from_place('USA', network_type='drive')

orig_node = ox.get_nearest_node(G, (lat, lon))
dest_node = ox.get_nearest_node(G, (lat, lon))

nx.shortest_path_length(G, orig_node, dest_node, weight='length')

Any efficient methods to do this?

I did see this post..

python osmnx - extract only big freeways of a country

but even just the freeways in the US will create a huge network

like image 429
cmj29607 Avatar asked Oct 30 '25 14:10

cmj29607


1 Answers

Given the enormity of your study site and the likely limitations of your computer, your best bet may be to first download an OSM extract then load it with OSMnx's graph_from_xml function.

like image 98
gboeing Avatar answered Nov 02 '25 05:11

gboeing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!