ducklet

guide

Map live earthquakes with SQL in the browser

Read the USGS earthquake feed live with DuckDB in your browser, count quakes by day and magnitude, and put them on a map. Every step is a SQL file you can change.

The US Geological Survey publishes every earthquake it records as open data, updated every minute, as CSV and GeoJSON. Browsers are allowed to read it, so DuckDB in your tab can query it live: no server, no download step.

Read the feed

SELECT time, mag, place, depth, latitude, longitude
FROM 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv'
ORDER BY mag DESC
LIMIT 20

That is a month of quakes, typically about ten thousand rows, read in a second or two. In ducklet a source like this is a small file, connections/quakes.toml, so every query can say FROM quakes.

Count them

SELECT date_trunc('day', time) AS day, count(*) AS quakes
FROM quakes
GROUP BY ALL
ORDER BY day

chart line on that query is a chart of quakes per day. Group by floor(mag) instead and chart barlist shows how rare the strong ones are.

Put them on a map

A query with longitude and latitude columns is a map. Size each quake by magnitude and colour it by depth, and the subduction zones draw themselves: shallow quakes along the trenches, deeper ones further inland, where the diving plate has gone down.

See it built

The Earthquakes, last 30 days app is this guide finished: a dashboard with the counts, the map, a replay through the month and a 3D slice across five trenches. Open it, then "edit it in ducklet" to read every query behind it. To look at a GeoJSON feed on its own, try the GeoJSON viewer.

open 🌋 Earthquakes, last 30 days →about this app ›try it with your own file: GeoJSON viewer ›