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

Extracting features that are inside a polygon set with overpass api

0

I need to display school building. i have made the outer area of school and tagged it as amenity=school. there are some buildings inside the area, i need the data of the buildings.

using overpass api's around clause i can get them but it also gives some buildings that are outside the school. i am trying to use the area or pivot clause, but the results are empty. the overpass query is

(way({{bbox}})['amenity'~'school|college|hospital|clinic'];node(w);)->.boundary;(way(area.boundary);node(w););out skel;

the test area

it should be like this

P.S. all the building have been tagged as building=school, which gives a shorter query. but i need to use the area clause because they might not be tagged properly in other places.

asked 08 Apr '13, 19:35

amritkarma's gravatar image

amritkarma
684212941
accept rate: 11%


One Answer:

5

The areas in Overpass API are generated for ways with specific tags only, for example for ways with a name and "area=yes" or a name and any value of "landuse".

I would recommend to retag way 142778170 with "amenity=school" and "area=yes" instead of "area=school". Then Overpass API would generate in the next run an area for that campus. This may take some hours, the timestamp "areas" in the meta tag of the returned data must become newer than your edit. Then you can select the buildings with

way[amenity=school]({{bbox}});
node(w);is_in;
area._[amenity=school];
(
  way(area)[building];
  node(w);
);
out;

like in this example.

answered 11 Apr '13, 06:20

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

does it work for amenity=college,hospital,clinic? it has been tagged as amenity = college

(11 Apr '13, 07:45) amritkarma

Looks like it works for hospitals and schools, but not for colleges and clinics. Is there any workaround for colleges and clinics.

(11 Apr '13, 09:12) amritkarma

Please try again. I have enlarged the scope of the areas, at least on overpass-api.de

(16 Apr '13, 20:43) Roland Olbricht

Source code available on GitHub .