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, 11:33

Alejandra's gravatar image

Alejandra
112
accept rate: 0%


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.

permanent link

answered 05 Jan, 11:54

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
79.7k907011232
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×1

question asked: 05 Jan, 11:33

question was seen: 180 times

last updated: 05 Jan, 11:54

Related questions

powered by OSQA