Search code examples
openstreetmaposrm

Get Node from Coordinates (long, lat) in Open street maps


Using OSRM API, I found the coordinates of the intersections along a route.

I want to know what are the corresponding node IDs. Is there any API to find the node IDS from the coordinate points?


Solution

  • Is there any API to find the node IDS from the coordinate points?

    Yes. You need to pass annotations=nodes as additional query parameter. routes[i].legs[j].annotations.nodes will be an array of OSM IDs that you can use to link the data with OSM.

    Linking this to the coordinates in the step is a little bit complicated: You would need to concatenate all RouteStep.geometry and remove the duplicated coordinates (steps[i].geometry[-1] == steps[i+1].geometry[0]).