Using Kepler GL to Visualise over 35,000 Earthquakes near Christchurch, New Zealand

Mark Mayo
ITNEXT
Published in
5 min readMay 27, 2021

--

This is a step-by-step tutorial showing how I used Kepler GL to visualise 35,000 earthquakes over a period of 14 or so years in or around Christchurch, New Zealand.

From their site, “Kepler.gl is a data agnostic, WebGL empowered, high-performance web application for geospatial analytic visualizations.”. To me, that’s a way to view data in unique or interesting ways, which gets my attention. So I sat down for an evening to play, to see if I could visualise the earthquakes from New Zealand — specifically Christchurch and Kaikoura in Canterbury, over the last 10 years. For those who are unaware, Christchurch had some devastating earthquakes in 2010–2011, followed by thousands of aftershocks, and Kaikoura up the coast had their own brutal shake in 2016.

First, the tech:

— Built with Deck.gl, Kepler.gl utilizes WebGL to render large datasets quickly and efficiently.

— You can easily drag and drop a dataset, add filters, apply scales, and do aggregation on the fly.

Built on React & Redux, Kepler.gl can be embedded inside your own mapping applications.

Getting Started

Data, we need data. To get all the earthquake data, Geonet is a government provided data source of earthquakes (as well as volcanic warnings and other such alerts). They’ve helpfully provided a Quake Search, which allows you to produce CSV files of a particular region, period and all the shakes in that time.

using Quake Search to filter Canterbury quakes

This provided a download link for a CSV file, the sample contents of which look like this:

so many earthquakes

Uploading the data

Clicking ‘Get Started’ on Kepler takes you to this page, which allows you to load data for the visualisation. This is where we load the CSV file:

data time

Note that this all happens client-side — your data isn’t shared — they’re careful to say ‘load’ and not ‘upload’.

Now that it’s loaded in, you’ll be presented with a map of…California. This is slightly annoying until you realise that the data isn’t really being used yet, it’s just loaded in. So to prepare, we’ll move the map to New Zealand, and set the base map to Satellite, so it’s not just a dark map:

spying on hobbits from space

Under the layers tab, we can see the csv file is loaded, and has 31k+ rows (think, each of those is a shake!).

Layering up

At this stage, we have a map, we have data loaded, now we want the data on the map. As a layer. So we click “Add Layer”, give it a name (“shakes”), and choose a basic point type. Kepler GL now helpfully asks for you to map fields from the csv file to their own Latitude, Longitude and Altitude fields. The fields from the csv file are conveniently shown:

Detour.

At this point you may notice other Basic types and want a play. For example, hex bins gives us essentially a heatmap of the quakes immediately:

But we’ll stick with the basic point types. It’s worth noting though while we’re looking at the above picture — it looks like some hard lines for boundaries — but that’s because from Geonet I requested ONLY quakes from Canterbury, so they stop at the borders with Otago, West Coast, Marlborough etc. It’s also cool to see how far out at sea they can be detected!

So back to points, which looks a little simpler:

Time for Time!

Great! But that doesn’t really show us when it happened, just…where. So we need time added somehow. This is where ‘Filters’ come in. Under the ‘Filters’ add a Filter, choose the ‘origin time’ and … wow, now we have a timeline!

even at this point, the two big events are very visible on the timeline

You can clearly see the main events time-wise, with the fading aftershocks over time.

Moving through time

This is nifty, and if you look at the timeline you can see two bars. You can move those to set a time window width:

And then hit play to see it all animating as time plays!

That’s cool, but it’s hard to tell the earthquakes apart. Which was the ‘big’ September quake? Where did the Kaikoura swam start?

Colouring based on magnitude

This is where the custom features of points come in. You can specify the colour to change based on a field — for this I’ll choose magnitude, and the radius to adjust based on this field too, although because of the wide variety (some ‘big’ shakes are too deep to feel), I’ll use the magntitude type here:

ooh, colours!

Time to hit play again and see how that looks!

Animated, with colours and relative radius adjustments

And there we have it. The whole process took me a couple of hours because I was playing with all the settings and writing this up. But, if you know what you’re doing, you can animate over 10 years of earthquake data in under 5 minutes, and look good doing it!

Final thoughts

This is a powerful platform that I’ve only just begun to play with, but there are so many opportunities for beautiful data to easily show huge amounts of information clearly and cleanly. Take a look at the arc graph of commutes in England and Wales, for example:

If your city/town’s council is like mine, they probably have some public data that is just sitting there, waiting to be visualised. Why not give it a try now?

Note: The author is not associated with Kepler GL or GeoNet, but does appreciate their content very much.

--

--

Quality Assurance Advocate, Christchurch, New Zealand. Also a mad keen traveller. What's your favourite town to visit?