
How we visualized earthquake data using Preswald

Category: Use Case
Tracking and analyzing earthquake data from CSV files was a time-consuming, manual process. Our team relied on multiple tools to clean, filter, and visualize seismic activity data, making real-time insights difficult to generate.
We needed a way to automate earthquake analytics, eliminate repetitive tasks, and build interactive dashboards to help researchers, emergency responders, and data analysts gain real-time insights from historical earthquake records.
That’s when we turned to Preswald.
The Challenge: Slow and Manual Earthquake Data Processing
Our earthquake analytics workflow had several bottlenecks:
- 🌍 Data Spread Across Multiple CSV Files – Downloading and merging data from various sources was tedious.
- 🧼 Manual Cleaning and Filtering – Formatting inconsistencies meant constant adjustments.
- 📊 Basic Static Reports – We relied on Excel and static charts, which lacked interactivity.
- 😩 Inefficient Scripting – Custom Python scripts were hard to maintain and deploy.
We needed a fast, automated, and interactive way to:
- Load and process CSV earthquake data in real-time.
- Filter and visualize earthquakes by magnitude, depth, and location.
- Deploy an interactive web dashboard without needing a frontend.
Why We Chose Preswald
Preswald provided an all-in-one solution to automate earthquake analytics:
- ✅ Instant CSV data ingestion – No manual importing or cleaning.
- ✅ Interactive dashboards with Python – No need for JavaScript or BI tools.
- ✅ Automated filtering and visualization – Earthquake trends in real-time.
- ✅ One-command deployment – Shareable dashboards in minutes.
The Implementation: From Static Reports to Live Dashboards
Step 1: Installing Preswald
We started by installing Preswald:
pip install preswald
Step 2: Setting Up the Earthquake Analytics App
We created a new Preswald project:
preswald init earthquake_dashboard
cd earthquake_dashboard
This automatically generated a pre-configured structure, including:
hello.py
– The main earthquake analytics script.preswald.toml
– Configuration for themes and settings.secrets.toml
– Secure storage for sensitive credentials.
Step 3: Loading and Connecting to Earthquake Data (CSV)
Instead of manually loading data every time, we automated CSV ingestion:
import pandas as pd
from preswald import connect, get_df, text, table, slider, plotly
import plotly.express as px
# Title
text("# Earthquake Analytics Dashboard 🌍")
# Load earthquake data from CSV
connect()
data = get_df("earthquake_data")
# Display raw data
table(data)
✅ No more manual file uploads – Preswald reads CSVs dynamically.
Step 4: Filtering Earthquake Data by Magnitude
To allow users to filter earthquakes based on severity, we added a magnitude slider:
# Slider for filtering magnitude
min_magnitude = slider("Minimum Magnitude", min_val=0.0, max_val=10.0, default=5.0)
# Convert Magnitude column to numeric and filter data
data["Magnitude"] = pd.to_numeric(data["Magnitude"], errors="coerce")
filtered_data = data[data["Magnitude"] >= min_magnitude]
# Show filtered earthquakes
table(filtered_data)
# Summary statistics
text(f"### Total Earthquakes with Magnitude ≥ {min_magnitude}: {len(filtered_data)}")
✅ Instant filtering – Users can adjust the magnitude threshold dynamically.
Step 5: Visualizing Earthquake Locations on an Interactive Map
Using Plotly, we generated an interactive map of earthquake locations:
# Interactive map using Plotly
text("## Earthquake Locations")
fig_map = px.scatter_geo(
filtered_data,
lat="Latitude",
lon="Longitude",
color="Magnitude",
size="Magnitude",
hover_name="ID",
title="Earthquake Map",
)
plotly(fig_map)
✅ No complex GIS software needed – The map updates dynamically based on selected filters.
Step 6: Analyzing Earthquake Magnitudes and Depths
We added two key visualizations to help users analyze magnitude distribution and depth impact:
# Magnitude distribution histogram
fig_hist = px.histogram(
filtered_data, x="Magnitude", nbins=20, title="Distribution of Magnitudes"
)
plotly(fig_hist)
# Depth vs. Magnitude scatter plot
fig_scatter = px.scatter(
filtered_data,
x="Depth",
y="Magnitude",
color="Magnitude",
title="Depth vs Magnitude",
labels={"Depth": "Depth (km)", "Magnitude": "Magnitude"},
)
plotly(fig_scatter)
✅ Clear trends – Users can spot patterns between depth and earthquake severity.
Step 7: Running the Dashboard Locally
With just one command, our dashboard was live:
preswald run
📍 The app was instantly available at:
🌐 http://localhost:8501
Step 8: Deploying to the Cloud for Public Access
To make the dashboard accessible to researchers worldwide, we deployed it to the cloud:
preswald deploy --target structured
✅ Anyone can now interact with real-time earthquake data without needing Python installed.
The Results: Real-Time, Automated Earthquake Analysis
🚀 Transformed static CSV files into an interactive web dashboard
🚀 Eliminated manual filtering and visualization work
🚀 Enabled real-time earthquake tracking with dynamic controls
🚀 Deployed a shareable cloud dashboard in minutes
Final Thoughts: Preswald for AI-Driven Data Analytics
If your team struggles with analyzing large CSV datasets manually, Preswald is a game-changer. It allows you to build interactive, AI-powered dashboards in Python without complex frontend coding.
Ready to revolutionize your data analytics?
🚀 Try Preswald today!