Overview

The aim in this report is to create and display an interactive map of recent earthquakes around Italy and the surrounding seas. Data is taken from the Italian National Institute of Geophysics and Volcanology which provides detailed information about earthquakes available to download.

Data Processing

Getting the Raw Data

Data available at the INGV page is taken using the INGV webservices and downloaded as a text file to a local file.

if(!file.exists('earthquakes.txt')) {
  download.file('http://webservices.ingv.it/fdsnws/event/1/query?starttime=2017-10-09T00%3A00%3A00&endtime=2017-10-16T23%3A59%3A59&minmag=2&maxmag=10&mindepth=-10&maxdepth=1000&minlat=-90&maxlat=90&minlon=-180&maxlon=180&minversion=100&orderby=time-asc&format=text&limit=10000', destfile = 'earthquakes.txt', method = "curl")
}

Reading the Data

library(dplyr)
library(lubridate)
library(leaflet)

The downloaded file is a simple text with header and columns delimited by ‘|’.

df <- read.csv('earthquakes.txt', header=TRUE, sep="|")
str(df)
## 'data.frame':    63 obs. of  13 variables:
##  $ X.EventID        : int  17280571 17285641 17286531 17286991 17288681 17289441 17290341 17290871 17292271 17293271 ...
##  $ Time             : Factor w/ 63 levels "2017-10-09T05:22:18.970000",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ Latitude         : num  43 42.7 42.8 38.8 42.8 ...
##  $ Longitude        : num  13.1 13.1 13.2 15.6 13.2 ...
##  $ Depth.Km         : num  9.1 10.4 10.3 88.4 10.3 118 11.9 19.5 12.3 10.5 ...
##  $ Author           : Factor w/ 3 levels "SURVEY-INGV",..: 1 1 1 1 1 1 1 2 1 1 ...
##  $ Catalog          : logi  NA NA NA NA NA NA ...
##  $ Contributor      : logi  NA NA NA NA NA NA ...
##  $ ContributorID    : logi  NA NA NA NA NA NA ...
##  $ MagType          : Factor w/ 3 levels "Md","ML","Mwp": 2 2 2 2 2 2 2 3 2 2 ...
##  $ Magnitude        : num  2.5 2 2.4 2.2 2 2.3 2.2 6.2 2 2.2 ...
##  $ MagAuthor        : Factor w/ 1 level "--": 1 1 1 1 1 1 1 1 1 1 ...
##  $ EventLocationName: Factor w/ 45 levels "1 km NE Monte Cavallo (MC)",..: 24 36 32 45 32 41 26 44 28 9 ...

Filtering Data

We add a column to provide the earthquake location, time and magnitude as popup information when selected by the user on the map:

df <- df %>%
      mutate(popup = paste(sep = "<br>", 
                           EventLocationName, 
                           Time, 
                           paste(sep = " ", MagType, Magnitude)))

Interactive Earthquakes Map

Finally, the map is rendered where each earthquake is marked by a circle with radius proportional to its magnitude squared. The earthquakes are clustered on the map:

leaflet(df) %>% 
  addTiles() %>%
  setView(13,41.5,zoom=6) %>%
  addCircleMarkers(lat = ~Latitude, lng = ~Longitude, 
                   radius = ~Magnitude^2, 
                   clusterOptions = markerClusterOptions(), 
                   popup = ~as.character(popup))