Search code examples
openstreetmapoverpass-api

How can I get a list of (lat, lon) pairs for a way in a single call to the OSM API?


Given the ID of a Way in OSM, I'd like to get a list of (lat, lon) pairs.

If I request the way via the standard API, I get a list of Node IDs:

$ curl 'http://www.openstreetmap.org/api/0.6/way/158602261'
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" ...>
 <way id="158602261" visible="true" ...>
  <nd ref="295505187"/>
  <nd ref="1736599935"/>
  <nd ref="295505112"/>
  ...
</osm>

I can then do follow-up queries for each of these nodes:

$ curl 'http://www.openstreetmap.org/api/0.6/node/295505187'
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" ...>
  <node id="295505187" visible="true" ... lat="37.7702484" lon="-122.5107188"/>
</osm>

But this will require many API requests, one per node in the path.

Is it possible to get the list of lat/lons using fewer API calls? Just one call would be ideal.


Solution

  • Just append /full to the URL, e.g. http://www.openstreetmap.org/api/0.6/way/158602261/full.