Big Data 11 min read

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.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Analyze 10 Years of Chinese Earthquake Data with Python

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 preview
Data preview

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_list

After execution, the dataset now contains Gaode coordinates.

Coordinate conversion result
Coordinate conversion result

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.hour

3. 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['省'] = provinces

The enriched dataset now includes accurate province and city information.

Location enrichment
Location enrichment

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.

Moderate earthquake count
Moderate earthquake count

Define magnitude ≥4.7 as “destructive”. There were 505 destructive earthquakes in the same period, averaging about 50 per year.

Destructive earthquake count
Destructive earthquake count

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

Provincial earthquake bar chart
Provincial earthquake bar chart

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).

City earthquake counts
City earthquake counts

4. Spatial Visualizations

Scatter map of destructive earthquakes (latitude/longitude).

Destructive earthquake scatter map
Destructive earthquake scatter map

Heatmap of all earthquake locations.

Earthquake heatmap
Earthquake heatmap

Dynamic heatmap showing monthly distribution over the past ten years.

Dynamic monthly heatmap
Dynamic monthly heatmap

5. Supplementary Knowledge

Earthquake belt map based on magnitude ≥5.

Earthquake belt
Earthquake belt
5+ magnitude distribution
5+ magnitude distribution

Feel free to try the code yourself, and join the Python learning group for further discussion.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Data visualizationGeocodingFoliumEarthquake Data
Python Crawling & Data Mining
Written by

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!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.