NOTICE: is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum


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 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{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

nonProfitDeveloper's gravatar image

accept rate: 0%

Overpass-API has functionality to retrieve the nodes:

Typically you'd do something like


where the way[...]; is what you are doing to find the ways, and then >; adds the results to the union.

permanent link

answered 27 Jan '21, 02:06

maxerickson's gravatar image

accept rate: 32%

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:

However keep in mind that this API is primarily for editing OSM data. Don't perform bulk requests against it.

permanent link

answered 27 Jan '21, 08:41

scai's gravatar image

scai ♦
accept rate: 23%

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 geom

Using out geom output:

out geom;

writes the node coordinates to an additional geometry property in the way object:

"geometry": [
  { "lat": 44.4198143, "lon": 38.2052864 },
  { "lat": 44.4196878, "lon": 38.2052733 },
  { "lat": 44.4195565, "lon": 38.2052576 }

No need to include the full node objects in the result.

GeoJSON format

Using the Geometry operator geom() in a convert statement:

convert item ::=::,::geom=geom(),_osm_type=type();
out geom;

converts the way object into a derived object with the given properties and writes the coordinates into the geometry property in the GeoJSON format:

"geometry": {
  "type": "LineString",
  "coordinates": [
    [38.2052864, 44.4198143],
    [38.2052733, 44.4196878],
    [38.2052576, 44.4195565]

See also:

permanent link

answered 28 Jan '21, 19:58

ikonor's gravatar image

accept rate: 18%

edited 28 Jan '21, 20:05

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 27 Jan '21, 01:34

question was seen: 6,482 times

last updated: 19 Feb '21, 07:00

NOTICE: is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum