问题
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:
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;
来源:https://stackoverflow.com/questions/31046501/how-to-get-points-from-openstreetmap-of-a-certain-country