This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Overpass API: get adjacent nodes beyond bounding box?

0

I'm using Overpass QL to retrieve data for a bounding box (about 2 km square). I'd like to get:

  • all the nodes, ways, and rels within the box
  • all the ways and rels that reference these items
  • nearby nodes on included ways, for rendering

Currently, my request looks like this:

  [bbox:...];
  ( node; way; rel; );
  ( ._; <<; ); out;

This mostly works, but it doesn't give me nearby nodes on included ways, if the nodes are outside the box. So, for example, I can't draw the path the freeway takes heading out of the box. I'm afraid to use the >> operator, however, lest I get inundated by data (eg, every node on Interstate 10 :-). I could make my bounding box larger and clip the results, but that seems wasteful.

Comments, clues, suggestions?

-r

asked 16 Dec '17, 00:55

Rich_Morin's gravatar image

Rich_Morin
11112
accept rate: 0%


One Answer:

0

As a workaround, I'm currently using a pair of bounding boxes, as follows:

  • Use the "real" bounding box (b1) to get nodes, rels, and ways.
  • Recurse upward to get referencing rels and ways.
  • Fold in nodes from a slightly larger bounding box (b2).

Making b2 20% wider and taller than b1 produces clean results, at the cost of downloading about 30% more data. Currently, my request looks something like this:

( node(b1); way(b1); rel(b1); );
( ._; <<; node(b2); ); out;

Still hoping for a cleaner solution...

-r

answered 16 Dec '17, 04:49

Rich_Morin's gravatar image

Rich_Morin
11112
accept rate: 0%