This document was inspired by Neil Saunders’ recent post mapping New Zealand earthquake data. This document shows how to make an interactive map using the leaflet package for R.
Sources of publicly-available earthquake data include NZ GeoNet and the USGS earthquake site. USGS API queries appear to be limited to magnitude 2.5+ (even when smaller magnitudes are specified). So we use the GeoNet website to obtain URLs for data from 2010 - present, then combine into one large data frame.
First we need a map of New Zealand. This is fairly straightforward using leaflet.
To map by magnitude we use addCircles(). Circles are sized and colored by magnitude. The popup gives more detail. The full data set contains 154349 points; this map shows only the earthquakes with magnitude at least 4.
This shows the recent strong earthquakes in the Canterbury region, including the 2016 Kaikoura earthquake (the red dot north-east of Christchurch).