These few lines of code took almost 10minutes to return me a number of meters between two locations. But using the same coordinates in here takes less than 1 second. In my code I haven't even requested to plot the route on the graph, just needed a distance between two coordinates.
Can I achieve the same quick online response speed from the python code?
This code with 10min response:
import osmnx as ox
G = ox.graph.graph_from_place("Vestland, NORWAY", network_type='drive')
558.1109199523926
A = ox.distance.nearest_nodes(G, 5.462695, 60.433214, return_dist=False)
1.176299810409546
B = ox.distance.nearest_nodes(G, 5.770288, 60.392021, return_dist=False)
0.1539440155029297
route = ox.distance.shortest_path(G, A, B, weight='length', cpus=None)
0.0059931278228759766
edge_lengths = ox.utils_graph.get_route_edge_attributes(G, route, "length")
0.0
total = round((sum(edge_lengths)))
0.0
print(total)
EDIT:
I inserted the time for executing each line of the code, see above