I am currently trying to use OSRM's Table service to get the durations of the fastest routes between two points, to be able to build a time matrix using Python and later use it as a parameter in an optimization problem.

My problem is that whenever I run my own server through my jupyter notebook (using five different locations) the 'durations' array returns empty, like in the following example:

str_locations = '-30.59464,-71.19366;-30.60386,-71.21342;-30.58654,-71.18429;-30.60298,-71.20075;-30.58603,-71.19196'


[0, 0, 0, 0, 0]

I've already checked that those points exist and are connected using the two first points in map.project-osrm.org (here's the link). Plus, whenever I replace the local server with the online demo (http://router.project-osrm.org/) the array is not empty, but that doesn't work with more than 100 coordinates and I need at least 250.

I think it could have something to do with the algorithm that I am using, MLD rather than CH?

  • Can you share the exact query to the live server that works? – alphabetasoup Nov 25 '18 at 8:31
  • This is the query that works but returns an empty array 'http://localhost:5000/table/v1/driving/-30.59464,-71.19366;-30.60386,-71.21342;-30.58654,-71.18429;-30.60298,-71.20075;-30.58603,-71.19196?sources=0'. And when I put it on the demo server like this: link It says that there is no route between them. Those points all are situated in the same town and when I use the example query the same thing happens. – monacroma Nov 25 '18 at 14:43

Your latitude and longitude are in the incorrect order.

For example, this query works:


But it returns a bad response when the coordinate order is swapped.

Additionally, here's a different way to declare and use your lat/lon tuples in your code. Doing it with an array of a lat/long tuples makes it so that these kinds of errors are easier to fix, and your code is more generic.

host = 'http://localhost:5000/'
path = 'table/v1/driving/'
waypoints = [(-30.59464,-71.19366),(-30.60386,-71.21342),(-30.58654,-71.18429),(-30.60298,-71.20075),(-30.58603,-71.19196)]
waypoints = ';'.join(map(lambda pt: '{},{}'.format(*reversed(pt)), waypoints))
r = requests.get('{}{}{}?sources=0'.format(host, path, waypoints))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.