I'm am on a project that would like to obtain the GPS boundaries of objects/locations of interest in JSON format. We have found it possible to make a single API call to http://overpass-api.de/api/interpreter? to get a list of ways with node ID's. We then found that we could traverse the list and make another API call to https://api.openstreetmap.org/api/0.6/node/{nodeID}.json to obtain the individual node coordinates. Is there a more efficient process in retrieving this information as some ways could have up to 2000 nodes? Thanks for the information in advance! asked 27 Jan '21, 01:34 nonProfitDev... |
Overpass-API has functionality to retrieve the nodes: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Recurse_down_.28.3E.29 Typically you'd do something like
where the answered 27 Jan '21, 02:06 maxerickson Thank you, I was not aware of the recurse down feature.
(19 Feb '21, 02:57)
nonProfitDev...
Have you looked at my answer, which shows better ways to get just the coordinates, if you're not interested in the node objects?
(19 Feb '21, 07:00)
ikonor
|
You can retrieve a way and all of its nodes directly from the OSM API: https://www.openstreetmap.org/api/0.6/way/1010/full However keep in mind that this API is primarily for editing OSM data. Don't perform bulk requests against it. answered 27 Jan '21, 08:41 scai ♦ |
Beside recurse down (>), Overpass API offers additional options to resolve the node references of a way and to get the coordinates of the nodes: out geomUsing
writes the node coordinates to an additional
No need to include the full node objects in the result. GeoJSON formatUsing the Geometry operator
converts the way object into a derived object with the given properties and writes the coordinates into the
See also: answered 28 Jan '21, 19:58 ikonor |