You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
692 B
28 lines
692 B
7 months ago
|
from pathlib import Path
|
||
|
import json
|
||
|
|
||
|
|
||
|
# 读取作为字符串的数据并转换为Python对象。
|
||
|
path = Path('eq_data/eq_data_1_day_m1.geojson')
|
||
|
contents = path.read_text()
|
||
|
all_eq_data = json.loads(contents)
|
||
|
|
||
|
# 获取数据集中地震列表。
|
||
|
all_eq_dicts = all_eq_data['features']
|
||
|
|
||
|
mags, titles, lons, lats = [], [], [], []
|
||
|
for eq_dict in all_eq_dicts:
|
||
|
mag = eq_dict['properties']['mag']
|
||
|
title = eq_dict['properties']['title']
|
||
|
lon = eq_dict['geometry']['coordinates'][0]
|
||
|
lat = eq_dict['geometry']['coordinates'][1]
|
||
|
mags.append(mag)
|
||
|
titles.append(title)
|
||
|
lons.append(lon)
|
||
|
lats.append(lat)
|
||
|
|
||
|
print(mags[:10])
|
||
|
print(titles[:2])
|
||
|
print(lons[:5])
|
||
|
print(lats[:5])
|