I am using the OSRM API to (1) determine the nearest point on a road segment from a give random point with


The returned coordinates are used then as an input to (2) determine the route between this point and an other give point on a road segment with


Every now and then the point determined in step (1) is located on a non routable road (e.g. private road).

I am looking for a way to work around this problem.

a) Is there a way to determine in step (1) the next closest point on a different road segment or only query road segments on routable roads.


b) Is there a way that the routing query in (2) automatically determines the next closest routable point?

I am also open for different solutions. However I am not interested in setting up my own server with pgrouting or similar services. I like to solve it with an open source routing API (preferable with the OSRM one).

The request is done from a python script (requests and json).

  • can you somehow avoid importing those 'unroutable' roads?
    – Karussell
    Commented Jun 7, 2013 at 7:23
  • Well they are part of OSM. I only use an API and don't see a way how I could influence what is imported and what not.
    – ustroetz
    Commented Jun 7, 2013 at 14:13
  • I understand. You could file a bug report IMO there. Also what area are you looking for? If it is rather small why not setup OSRM without the private roads?
    – Karussell
    Commented Jun 7, 2013 at 18:32
  • It is not a real bug of OSRM. It does find the closest road (1). And private routes are not routable (2). The area are the states California, Oregon and Washington of the United States. It is a lot of work to setup OSRM yourself. I am hoping to bypass it this somehow.
    – ustroetz
    Commented Jun 7, 2013 at 18:41
  • If the private roads are not routable then the location should not snap to those roads but that is my personal opinion. E.g. it also should not snap to foot path if the route is for CAR etc.
    – Karussell
    Commented Jun 7, 2013 at 18:48

1 Answer 1


Do you need this functionality with a few via nodes (in this case I think there is a very similar Google API) or for a detailed track ( i.e. map-matching )? Otherwise you'll have to setup OSRM with a selection of roads instead of the full OSM.

  • Well via nodes is also possible with OSRM, but that does not solve the problem. Also I am not interested in setting up my own server with OSRM. I am hoping there is a workaround and I still can use the OSRM API. But thanks for your ideas. Maybe I switch to the Google API instead.
    – ustroetz
    Commented Jun 6, 2013 at 20:45
  • 1
    in OSRM you can use the zoom level &z={0,...,18} to "ignore small isolated islands". Otherwise an ugly hack is to add a small noise to your location data when the returned locations are on non-routable streets. Commented Jun 17, 2013 at 9:02
  • Thanks for pointing that out. The small island isolatation isn't the problem. What exactly do you mean with adding small noise to my location data?
    – ustroetz
    Commented Jun 24, 2013 at 16:54
  • if you want to work around the limitation of this snapping mechanism, you could add a few meters in any direction till you find a snapped-routable road. It's not nice but it won't block you waiting for the snapping to be fixed. Did the zoom level solve this? Commented Jun 27, 2013 at 21:05
  • The zoom level doesn't solve the problem. But I understood you second point now with the small noise, but that is a pretty big and not so nice workaround of this problem. I guess I am better of setting up my own routing app.
    – ustroetz
    Commented Jun 27, 2013 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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