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

Overpass API Condition for GeocodeArea & BoundingBox

2

I could able to retrieve data using BoundingBoxes or GeocodeArea using over-pass API. While i want to get specific information from particular GeocodeArea i use

 {{geocodeArea:India}}->.searchArea;

For BoundingBoxes I use like

  node["leisure"="park"](50.6,7.0,50.8,7.3);

How Can i prepare Overpass query condition that satisfies both BBox & GeocodeArea. Any Examples? Any Help would be appreciated.

asked 05 Dec '15, 11:00

suri1983's gravatar image

suri1983
46114
accept rate: 0%

edited 05 Dec '15, 11:01

As far as I know you can only limit one query by either bbox or area parameter ... there is no combination feature in overpass-api documentation.

But maybe you can do a difference between one result from the other and get a result you want. See https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Difference

(07 Dec '15, 17:11) stephan75

One Answer:

4

You can simply combine multiple filters in one query statement. In the following example we're looking for all pubs in Cologne (inside relation 62578), which in addition are inside a given bounding box. The resulting query should look like this:

area(3600062578)->.searchArea;
node
  ["amenity"="pub"]
  (area.searchArea)
  (50.91928498040378,6.7814483642578125,51.03858753963086,6.8932342529296875);
out body;

Overpass Turbo Link: http://overpass-turbo.eu/s/ddV

If you leave out the (area.searchArea) line in overpass turbo, you'll notice some additional pubs, whcih are inside the bounding box, but not in the Cologne area.

answered 11 Dec '15, 17:32

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

edited 11 Dec '15, 17:36

Thank you all. Its kind of fun with OSM.

(12 Dec '15, 18:14) suri1983
1

@mmd, may i know why is the 36000 number is prefixed with relation id?

(27 May '16, 10:12) yogi_ks
2

@yogi_ks: it's simply a convention which is only used for Overpass API: read more about it on the wiki page.

By convention the area id can be calculated from an existing OSM way by adding 2400000000 to its OSM id, or in case of a relation by adding 3600000000 respectively

(27 May '16, 11:43) mmd

@mmd: thank you for the explanation.

(27 May '16, 12:11) yogi_ks

Source code available on GitHub .