如何从某个国家的 OpenStreetMap 获取积分?

How to get points from OpenStreetMap of a certain country?

我正在尝试获取我所在国家/地区所有学校的列表,经过多次尝试,我编写了以下查询,该查询在 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;

我用geocodeBbox到select意大利的所有学校因为geocodeIdgeocodeArea(请参考documentation)给我以下错误:

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

无论如何,问题是查询 select 甚至是不在意大利的学校(例如有一所来自克罗地亚的学校)。

那么,如何准确获取某个国家的积分呢?

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

没错。边界框 (bbox) 是一个矩形,而不是多边形。因此它总是会包含更多一点,除非你有一个矩形国家也与给定的 bbox 完美对齐;)

试试这个查询:

[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;