立交桥查询适用于立交桥-turbo.eu,但不适用于本地
Overpass query works on overpass-turbo.eu, but not locally
我正在尝试从 Python 脚本执行 Overpass 查询。我在 overpass-turbo.eu 练习并发现以下查询按预期工作:
[out:json][timeout:600];
{{geocodeArea:Niedersachsen}}->.searchArea;
(
node[place=city](area.searchArea);
node[place=town](area.searchArea);
);
out;
但是,当我从 Python 脚本提交完全相同的查询时,出现错误:
import requests
overpass_query = """
[out:json][timeout:600];
{{geocodeArea:Niedersachsen}}->.searchArea;
(
node[place=city](area.searchArea);
node[place=town](area.searchArea);
);
out;
"""
overpass_url = "http://overpass-api.de/api/interpreter"
response = requests.get(overpass_url, params={'data': overpass_query})
data = response.json()
/home/enno/events/docker/etl/venv/bin/python /home/enno/events/docker/etl/test2.py
Traceback (most recent call last):
File "/home/enno/events/docker/etl/test2.py", line 16, in <module>
data = response.json()
File "/home/enno/events/docker/etl/venv/lib/python3.6/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Process finished with exit code 1
这是为什么?好像和花括号有关,但是我不知道怎么解决。
非常感谢,
恩诺
大括号(又名 {{geocodeArea:Niedersachsen}}
)是立交桥 Turbo 的一个特殊功能,不是立交桥 API 的一部分。有关这些快捷方式的列表,请参阅 extended overpass turbo queries。
{{geocodeArea:name}}
将告诉 overpass turbo 在您的程序中使用 Nominatim. It will then use the first result to construct an area(id)
query. You have to perform the same step (using Nominatim or any other geocoder) 执行地理编码请求。
我正在尝试从 Python 脚本执行 Overpass 查询。我在 overpass-turbo.eu 练习并发现以下查询按预期工作:
[out:json][timeout:600];
{{geocodeArea:Niedersachsen}}->.searchArea;
(
node[place=city](area.searchArea);
node[place=town](area.searchArea);
);
out;
但是,当我从 Python 脚本提交完全相同的查询时,出现错误:
import requests
overpass_query = """
[out:json][timeout:600];
{{geocodeArea:Niedersachsen}}->.searchArea;
(
node[place=city](area.searchArea);
node[place=town](area.searchArea);
);
out;
"""
overpass_url = "http://overpass-api.de/api/interpreter"
response = requests.get(overpass_url, params={'data': overpass_query})
data = response.json()
/home/enno/events/docker/etl/venv/bin/python /home/enno/events/docker/etl/test2.py
Traceback (most recent call last):
File "/home/enno/events/docker/etl/test2.py", line 16, in <module>
data = response.json()
File "/home/enno/events/docker/etl/venv/lib/python3.6/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Process finished with exit code 1
这是为什么?好像和花括号有关,但是我不知道怎么解决。
非常感谢,
恩诺
大括号(又名 {{geocodeArea:Niedersachsen}}
)是立交桥 Turbo 的一个特殊功能,不是立交桥 API 的一部分。有关这些快捷方式的列表,请参阅 extended overpass turbo queries。
{{geocodeArea:name}}
将告诉 overpass turbo 在您的程序中使用 Nominatim. It will then use the first result to construct an area(id)
query. You have to perform the same step (using Nominatim or any other geocoder) 执行地理编码请求。