这是我的JSON:
{
"version": 0.6,
"generator": "Overpass API 0.7.56.1004 6cd3eaec",
"osm3s": {
"timestamp_osm_base": "2020-05-01T10:56:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "way",
"id": 196511254,
"nodes": [
247532020,
3433695944,
7274513850,
247527633
],
"tags": {
"access": "no",
"access:conditional": "delivery @ (05:00-13:00)",
"bicycle": "yes",
"foot": "yes",
"highway": "residential",
"maxspeed": "30",
"maxspeed:zone": "yes",
"name": "De Keyserlei",
"note": "access = no according to traffic sign",
"psv": "yes",
"surface": "asphalt",
"wikidata": "Q2207937",
"wikipedia": "nl:De Keyserlei"
}
}
]
}
我设法编写代码,获取参数“elements”,然后打印它。但在“元素”中也有“标签”,然后是“maxspeed”
def get_speed_limit():
radius = 1
lat = 51.217473152637275
lon = 4.418572667839149
result = """https://overpass-api.de/api/interpreter?data=[out:json][timeout:25];way(around:"""+str(radius)+""","""+str(lat)+""","""+str(lon)+""")[maxspeed];out;"""
response = ox.requests.get(result)
data = response.json()
elements = data["elements"]
print(elements)
我的问题是如何提取更深层次的参数:“maxspeed”
(如果
data["elements"]
中有多个项目,则需要对其进行迭代)相关问题 更多 >
编程相关推荐