0

I'm looking for the correct way to query point/polygon elements that are

  1. name=* but neither tagged as amenity=school and building=school tags; and
  2. elements tagged as building=school but without a parent polygon that are tagged as amenity=school (to mark the school grounds)

I expect to see a list of nodes or ways that are tagged as building=school, but are not inside a closed way tagged as amenity=school. The purpose of the query is for Q&A of school-related elements in our region.

The following is the code I use to get the initial elements I'm interested in:

[out:json]
[timeout:25];
(
  node
    [name ~ "^.school.*$",i]["building"="school"]["amenity"!~"."]({{bbox}});
  way
[name ~ "^.school.*$",i]["building"="school"]["amenity"!~"."]({{bbox}});
);
//
// how to get parent poly for each resulting element?
//
// print results:
out body; 
>; 
out skel qt;
  • Does the surrounding way with amenity=school always have a name=* tag? If not, you cannot solve this with the official Overpass installation at this time. – mmd Dec 9 '15 at 13:00
  • 1
    For the first part of your question, please look up !~ in the Overpass QL documentation. – mmd Dec 9 '15 at 13:07
  • @mmd , not always. the amenity=school may, or may not be present. and we hope to improve the data where only buildings are tagged as schools, but not as as amenities. – n1kn0k Dec 9 '15 at 13:35
  • I'm not sure I'm following you. I was asking, if the surrounding amenity=school closed way always have a name=* tag. Now you replied that even the amenity=school may not be present. How should you determine, which closed ways are relevant then? Can you enhance your question a bit and provide some concrete examples? Also, I'd recommend to discuss this topic on the tagging mailing list first and get some feedback, if this kind of data improvement is generally accepted procedure. – mmd Dec 10 '15 at 11:45
  • Some mappers, probably new ones, would map a school as: name=*, building=school They sometimes forget to add a polygon for the school grounds, thinking that the building tag is sufficient. So the parent polygon for a school building, may or may not exist. I'm hoping to query for buildings tagged as schools, but without parent polygons that should've one marked as amenity=school. By the way, it's also possible to have buildings without school grounds in highly urban areas. Sorry for the inadequate explanation. English is not my first language. – n1kn0k Dec 11 '15 at 0:15
0

At the moment the closest possible approach is the following. It will return a number of false positives, because Overpass API doesn't have any area for ways with amenity=school, lacking a name=* tag.

[out:json]
[timeout:25];

// Retrieve (surrounding) ways with amenity=school
way({{bbox}})[amenity=school];

// convert ways to area for later area query
map_to_area ->.area;

(
  // Determine difference of all school buildings in bbox
  // minus those inside the closed way with an amenity=school tag

  // All nodes+ways with building=school and no amenity=* tag in bbox
  (
    node ["building"="school"]["amenity"!~"."]({{bbox}});
    way  ["building"="school"]["amenity"!~"."]({{bbox}});
  );
- // except for
  (
    // All nodes+ways with building=school and no amenity=* tag in area
    node ["building"="school"]["amenity"!~"."](area.area);
    way  ["building"="school"]["amenity"!~"."](area.area);    
  );
);

out geom;

Try it in overpass turbo: http://overpass-turbo.eu/s/der

  • I made a few modifications, but this got me very close to what I want to get out of OSM. Thank you. – n1kn0k Dec 14 '15 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.