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

How to query all elements within an outline way from Overpass API?

5

Given the id of a closed way which represents an area, as indicated by an "area" tag such as building=*, how can I retrieve all nodes/ways contained entirely or partially within that area from Overpass API?

What I have found so far is area-query, which sounds as if it should cover this use case, and it works as expected for areas represented as multipolygons (if you remember to add the magic number 3600000000 to the id):

<query type="node">
  <area-query ref="3600015228"/>
</query>

(Overpass Turbo)

I've found a hint that adding 2400000000 to the id might do the trick for closed ways. However, this does not appear to work:

<query type="node">
  <area-query ref="2501518744"/>
</query>

(Overpass Turbo)

This example query for way 101518744 should return 1172225070 as well as other nodes, but the result is empty. Is there something I'm missing?

asked 20 Mar '13, 18:40

Tordanik's gravatar image

Tordanik
12.0k15106147
accept rate: 35%


2 Answers:

8

In short: an area for the given way has never been generated because the way has no name. I'm sorry that there is no immediate solution to your problem.

In more detail: https://github.com/drolbr/Overpass-API/blob/master/rules/areas.osm3s contains the rules what objects are recognized as areas.

In particular, ways are selected there only if they have a name and one of various other tags (including "building=yes"). This ruleset isn't a fixed law, but rather reflects the discussion on the mailing list. It is likely to be incomplete anyway. Please send a mail to talk(at)openstreetmap.org to put the discussion further. I'll then expand the list when there is consensus that this is useful.

answered 21 Mar '13, 08:22

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

edited 21 Mar '13, 08:23

I've taken this to talk now, as you asked: Thread archive

(22 Mar '13, 20:03) Tordanik

1

Is there some changes/news regarding this question which seems important. It would be very useful to have the possibility to make queries using for exemple ways[landuse] without name.

Ex : Finding all residential buildings, all industrial buildings, etc. depending if they are included in ways with landuse=residential or landuse=industrial etc. but without any name. Most of the time, ways[landuse=residential] don't have name, then we can not use them as areas.

In my use, I need categories of buildings to determine activities surfaces (buildings) on ground. (Building attractions in terms of activities/population)

answered 26 Nov '13, 16:45

glider90's gravatar image

glider90
263
accept rate: 0%

3

Problem localy solved for me with the installation of a local Overpass server on wich we changed rules for areas (/rules/areas.osm3s). Thanks for this usefull post.

(27 Nov '13, 13:14) glider90

FYI: There are now two similar GitHub tickets dealing with this issue:

https://github.com/drolbr/Overpass-API/issues/77

https://github.com/drolbr/Overpass-API/issues/86

(21 Apr '14, 10:54) mmd

Source code available on GitHub .