我有这种形式的大量地理 json:
{'features': [{'properties': {'MARKET': 'Albany',
'geometry': {'coordinates': [[[-74.264948, 42.419877, 0],
[-74.262041, 42.425856, 0],
[-74.261175, 42.427631, 0],
[-74.260384, 42.429253, 0]]],
'type': 'Polygon'}}},
{'properties': {'MARKET': 'Albany',
'geometry': {'coordinates': [[[-73.929627, 42.078788, 0],
[-73.929114, 42.081658, 0]]],
'type': 'Polygon'}}},
{'properties': {'MARKET': 'Albuquerque',
'geometry': {'coordinates': [[[-74.769198, 43.114089, 0],
[-74.76786, 43.114496, 0],
[-74.766474, 43.114656, 0]]],
'type': 'Polygon'}}}],
'type': 'FeatureCollection'}
Run Code Online (Sandbox Code Playgroud)
阅读json后:
import json
with open('x.json') as f:
data = json.load(f)
Run Code Online (Sandbox Code Playgroud)
我将值读入列表,然后读入数据帧:
#to get a list of all markets
mkt=set([f['properties']['MARKET'] for f in data['features']])
#to create a list …Run Code Online (Sandbox Code Playgroud)