1

i'm trying to get the list of all schools in my country, and after several tries i write the following query that works with no errors on http://overpass-turbo.eu:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=school”=“yes”
*/
[out:json][timeout:60];
// gather results
(
  // query part for: “amenity=school”
  node[amenity=school]({{geocodeBbox:Italia}});
  way[amenity=school]({{geocodeBbox:Italia}});
  relation[amenity=school]({{geocodeBbox:Italia}});
);
// print results
out body;
>;
out skel qt;

I used geocodeBbox to select all schools of Italy because geocodeId and geocodeArea (please refer to documentation) give me the following errors:

Error: line 10: parse error: ')' expected - '(' found.

Error: line 11: parse error: ')' expected - '(' found.

Error: line 11: parse error: ';' expected - ')' found.

Error: line 12: parse error: ')' expected - '(' found.

Error: line 12: parse error: ';' expected - ')' found.

Error: line 13: parse error: Unknown type ")"

Error: line 13: parse error: An empty query is not allowed

Error: line 13: parse error: Unknown type ";"

Error: line 15: parse error: An empty query is not allowed

Anyway the problem is that the query selects even schools that are not in Italy (for example there is a school from Croatia).

So, how to get exactly the points from a certain country?

1

1 Answer 1

4

Anyway the problem is that the query selects even schools that are not in Italy (for example there is a school from Croatia).

That's correct. A bounding box (bbox) is a rectangle, not a polygon. Therefore it will always include a little bit more, except if you have a rectangle-shaped country that is also perfectly aligned with the given bbox ;)

Try this query instead:

[out:json][timeout:600];
// gather results
{{geocodeArea:Italia}}->.searchArea;
(
  // query part for: “amenity=school”
  node[amenity=school](area.searchArea);
  way[amenity=school](area.searchArea);
  relation[amenity=school](area.searchArea);
);
// print results
out body;
>;
out skel qt;
7
  • It collects even nodes without any references to "amenity:school" tag. These nodes contain just type, id, lat and lon tags. Why?
    – smartmouse
    Jun 27, 2015 at 14:29
  • 1
    Because it also collects ways (and relations) tagged with "amenity=school". The geometry of a way is defined by its referenced nodes. For more info read the section about OSM's basic elements.
    – scai
    Jun 29, 2015 at 6:42
  • Do you know any way to get nodes/ways without "duplicates"? I have to parse this data with PHP and i cannot handle recursive data with same node id.
    – smartmouse
    Jul 3, 2015 at 14:03
  • 1
    There shouldn't be any duplicates in the data returned. Maybe your parser is broken. The best is to create a new question, provide the data you are trying to parse, explain us your parser and tell us which data is supposed to be duplicated according to your parser.
    – scai
    Jul 4, 2015 at 10:09
  • 2
    Please read my second comment. You don't seem to be very familiar with the basic OSM elements. These are nodes belonging to "amenity=school" ways. These nodes don't also have this tag because that would be redundant. Instead only the way to which these nodes belong to has the amenity tag.
    – scai
    Jul 4, 2015 at 11:06

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.