This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

using routing based on past years

0

Hi I am trying to route some locations using Python code. However I want to use the routes if I was using the infrastructure available in 2010. How can I do this? i.e. Either calling an old version of a map (say a 2012 extraction - and how can I call this in my code?) or by restricting new routes (how to code that a specific route that is using was not there in 2012) ?

thanks!

def get_route(pickup_lon, pickup_lat, dropoff_lon, dropoff_lat):

loc = "{},{};{},{}".format(pickup_lon, pickup_lat, dropoff_lon, dropoff_lat)
url = "https://router.project-osrm.org//route/v1/driving/"
r = requests.get(url + loc) 
if r.status_code!= 200:
    return {}

res = r.json()   
routes = polyline.decode(res['routes'][0]['geometry'])
start_point = [res['waypoints'][0]['location'][1], res['waypoints'][0]['location'][0]]
end_point = [res['waypoints'][1]['location'][1], res['waypoints'][1]['location'][0]]
distance = res['routes'][0]['distance']
out= pd.DataFrame(routes)
return out

asked 05 Jan '22, 11:33

Alejandra's gravatar image

Alejandra
11112
accept rate: 0%


One Answer:

2

For this task, you cannot rely on a routing engine that someone else runs for you; you need to run the routing engine yourself. First grab the "history" file of the area you are interested in. Then, use the osmium utility to extract from this history file a snapshot for the day you want to compute the routing for. Then, set up a routing engine with this snapshot (https://github.com/Project-OSRM for the OSRM you seem to be using). This might require substantial resources if running for a large area (possibly more than 128 GB of RAM to compute a world-wide graph). Then finally, you can run your code against your local routing server (i.e. replace router.project-osrm.org with localhost:5001 or so).

It is important to understand that if you extract a 2010 snapshot from OSM data, you will see what OSM knew about the world in 2010, not what the world was like in 2010. For some countries, the 2010 road network will be extremely patchy simply because OSM was not widely used in that country at the time.

answered 05 Jan '22, 11:54

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%