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

Overpass : Query

0

Hello,
A school will have a number of buildings and they will be located close by. I tried with overpass the query which can select only one of these buildings and skip the rest. But not Proper working. Can you tell me the query for that ....
https://overpass-turbo.eu/s/ZEM
[out:json] [timeout:25]; way({{bbox}})[amenity=school]; map_to_area ->.area; ( ( node "building"="school"; way "building"="school"; )->.scl; ( ( node ["building"="school"]"amenity"!~"."; way ["building"="school"]"amenity"!~"."; ); - ( // All nodes+ways with building=school and no amenity=* tag in area node ["building"="school"]"amenity"!~"."; way ["building"="school"]"amenity"!~".";
);)->.samp1; ( node.samp1(around.scl:100); way.samp1(around.scl:100); )->.near; (.samp1; - .near;); ); out center;

asked 03 Nov '20, 12:11

VIPINDAS%20K's gravatar image

VIPINDAS K
1257813
accept rate: 0%

To start with, the {bbox} you provided there is no amenity=school so your first two lines will return nothing. Which building are you attempting to single out?

(03 Nov '20, 12:49) DaveF

school building (outside the tag "amenity = school")

(03 Nov '20, 13:38) VIPINDAS K

One Answer:

2

I /think/ you may have over complicated things. It's unclear if you wan one or all those outside

Edit:

https://overpass-turbo.eu/s/ZH6

[bbox:{{bbox}}];
(
  nw[building=school];
  -
  (
    way[amenity=school];map_to_area;
    nw(area)[building=school];
  );
)->.Outside;  
foreach .Outside (
  way.Outside(around:100);
  way._(if:count(ways) == 1);
  out center;
);

answered 03 Nov '20, 14:54

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 03 Nov '20, 17:10

This is exactly what is needed. But select only one school building and deselect the school building around it (within 100 meters). Is this possible?

(03 Nov '20, 15:07) VIPINDAS K

So you want all school buildings outside the perimeter of the school amenity, that are at least 100m away from other school buildings. Is that correct?

(03 Nov '20, 15:19) DaveF

Yes. (Select only one school building within 100 meter and skip the rest)

(03 Nov '20, 15:25) VIPINDAS K

I've updated the routine

(03 Nov '20, 17:11) DaveF

Thank you so much for your help .... Let there be 5 school buildings in one place (around 100 meters), select only one of them(and deselect the other school buildings). This is not possible in this query ... Can you include that too ....

(03 Nov '20, 19:16) VIPINDAS K

Source code available on GitHub .