I have a trace of GPS coordinates. I would like to get the OSM road ids of the roads that lie on the route defined by the coordinates.

I've used OSRM match service to match the coordinates to the road network. From the result I can get the individual node ids using annotations=true, but not the road ids. Should I somehow use the node id's to get the road ids, or is there some other way to achieve this?

  • 1
    It can't return the way IDs because your GPS trace doesn't have to pass along whole OSM ways but can use only part of these ways. So matching your trace to OSM ways means that you won't obtain a route but something like a tree instead with many branches. What is your ultimate goal?
    – scai
    Commented Sep 27, 2018 at 6:59
  • 1
    I understand that it does not pass along whole OSM ways, but I would still be interested in knowing the way IDs that the trace is on even for a short distance. My ultimate goal is to be able to pick the relevant roads from the OSM shapefile and save them to a separate shapefile.
    – poroale
    Commented Sep 27, 2018 at 7:30
  • 2
    Possible duplicate of Query for WAY that connects two INTERSECTIONS
    – mmd
    Commented Sep 28, 2018 at 15:14

2 Answers 2


You can use route-annotator, which was developed for use with OSRM, to look up way data given a set of OSRM-generated coordinates: https://github.com/mapbox/route-annotator


I suggest using Overpass API. You can test it at https://overpass-turbo.eu/

There you can find which ways are around certain coordinates. For example:

way(around:50,-38.01261, -57.55160)[name];

Will return all ways around coordinates (-38.01261, -57.55160) within a 50 mt radius which have a 'name' tag (this is to avoid ways that are not roads). You can play around with your own coordinates.

Don't bother around the map just yet, but check the 'Data' tab at overpass turbo. Looking the JSON, you will see the id.

In my example, way with ID #447325433 is returned. ;-)

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.