How to Analyze 10 Years of Chinese Earthquake Data with Python
This tutorial walks you through downloading the past decade of Chinese earthquake records, cleaning and enriching the dataset with coordinate conversion, timestamp parsing, and location extraction, and then visualizing statistics and maps—including province counts, city heatmaps, and dynamic monthly distributions—using Python, pandas, and Folium.
Data Acquisition
Download the past 10 years of earthquake data directly from the China Earthquake Network ( https://news.ceic.ac.cn/index.html?time=1637318776 ) and save the file locally.
Data Processing
1. Coordinate Conversion
The original latitude and longitude are in Baidu map coordinates, which need to be converted to Gaode (Amap) coordinates using the free Gaode API.
import requests
import pandas as pd
# Read data
df = pd.read_excel(r'eqList.xlsx')
longitude_list = []
latitude_list = []
# Baidu to Gaode conversion
for i, location in enumerate(df[['经度(°)', '纬度(°)']].values):
location = str(location[0]) + ',' + str(location[1])
url = 'https://restapi.amap.com/v3/assistant/coordinate/convert?'
parames = {
'locations': location,
'coordsys': 'baidu',
'key': 'YOUR_KEY',
}
r = eval(requests.get(url, params=parames).json()['locations'])
longitude_list.append(r[0])
latitude_list.append(r[1])
print(f'\r{i+1}', end='')
df['经度(°)'] = longitude_list
df['纬度(°)'] = latitude_listAfter execution, the dataset now contains Gaode coordinates.
2. Timestamp Processing
Convert the origin time to a datetime object, then extract month and hour for later analysis.
# Convert to datetime
df['发震时刻'] = pd.to_datetime(df['发震时刻'])
# Extract month (YYYY-MM)
df['月份'] = df['发震时刻'].apply(lambda x: str(x)[:7])
# Extract hour
df['小时'] = df['发震时刻'].dt.hour3. Province/City Extraction
Use the Gaode reverse‑geocoding API to obtain province and city names from the converted coordinates.
citys = []
provinces = []
for i, location in enumerate(df[['经度(°)', '纬度(°)']].values):
location = str(location[0]) + ',' + str(location[1])
url = 'https://restapi.amap.com/v3/geocode/regeo?'
params = {
'location': location,
'key': 'YOUR_KEY',
'extensions': 'base',
'batch': 'false',
'roadlevel': 0,
}
r = requests.get(url, params=params)
data = r.json()['regeocode']
city = data['addressComponent']['city']
province = data['addressComponent']['province']
if len(city) == 0:
city = province
citys.append(city)
provinces.append(province)
print(f'\r{i+1}', end='')
df['城市'] = citys
df['省'] = provincesThe enriched dataset now includes accurate province and city information.
Statistics and Visualization
Only simple descriptive statistics are performed; no predictive modeling is attempted.
1. Earthquake Counts
Define a magnitude range of 2–4.6 as “moderate” earthquakes. In the last ten years there were 6,188 moderate events, averaging over 600 per year.
Define magnitude ≥4.7 as “destructive”. There were 505 destructive earthquakes in the same period, averaging about 50 per year.
2. Provincial Distribution (Destructive Earthquakes)
Top provinces with the most destructive earthquakes:
Xinjiang – 98
Tibet – 63
Yunnan – 47
Taiwan – 47
Sichuan – 45
Qinghai – 32
Gansu – 10
Jilin – 9
Inner Mongolia – 7
Guangxi – 4
Hubei – 3
Guangdong, Hebei, Guizhou, Chongqing, Heilongjiang – 2 each
Jiangsu, Fujian, Liaoning, Shaanxi – 1 each
3. City‑Level Distribution (All Earthquakes)
Among the 233 cities that experienced earthquakes, the highest counts are in Xinjiang (e.g., Kizilsu Kirgiz Autonomous Prefecture – 491) and Sichuan (e.g., Yibin – 237).
4. Spatial Visualizations
Scatter map of destructive earthquakes (latitude/longitude).
Heatmap of all earthquake locations.
Dynamic heatmap showing monthly distribution over the past ten years.
5. Supplementary Knowledge
Earthquake belt map based on magnitude ≥5.
Feel free to try the code yourself, and join the Python learning group for further discussion.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
