4

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

cmj29607
  • 159
  • 1
  • 9

1 Answers1

2

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.

gboeing
  • 5,691
  • 2
  • 15
  • 41
  • I am querying OSMnx also for a very large study site (gpx route between Amsterdam and Rome - polygon of 1.5km radius around the route) for all the tourism places (I want all the area I could sleep: camp_sites, hotels etc.). Unfortunately, the API is only returning empty file to the cache... Is this caused by a too large study area? see: https://stackoverflow.com/questions/75144426/retrieve-campsites-within-a-specific-radius-around-a-gpx-route-from-osm – DeMelkbroer Jan 27 '23 at 12:08