我正在尝试从 JSON 数据集中从马萨诸塞州波士顿的多个社区中提取坐标,但我一直在尝试获取每个城市的第一个坐标对;下面是 Roslindale 坐标的缩小版。
"features": [{
"type": "Feature",
"properties": {
"Name": "Roslindale",
"Acres": 1605.5682375,
"SqMiles": 2.51,
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-71.125927174853857,
42.272013107957406
],
[
-71.125927174853857,
42.272013107957406
]
]
],
[
[
[
-71.125830766767592,
42.272212845889705
],
[
-71.125830766767592,
42.272212845889705
]
]
],
[
[
[
-71.125767203228904,
42.272315958536389
],
[
-71.125767203228904,
42.272315958536389
]
]
]
]
}
},
现在我已经提取了我想要使用的数据
for data in boston_neighborhoods:
neighborhood_name = data['properties']['Name']
neighborhood_id = data['properties']['Neighborhood_ID']
neighborhood_size = data['properties']['SqMiles']
neighborhood_latlon = data['geometry']['coordinates']
neighborhood_lat = neighborhood_latlon
neighborhood_lon = neighborhood_latlon
neighborhoods = neighborhoods.append({'Neighborhood': neighborhood_name,
'Neighborhood_ID': neighborhood_id,
'SqMiles': neighborhood_size,
'Latitude': neighborhood_lat,
'Longitude': neighborhood_lon}, ignore_index=True)
这将返回多个坐标对,但我只想要第一对,下面是我现在返回的示例输出:
Latitude | Longitude
--------------------------------------------------------
[[[[-71.12592717485386, | [[[[-71.12592717485386,
42.272013107957406], [... | 42.272013107957406], [...
qq_遁去的一_1
相关分类