EQVT is a Data Analysis and Visualization R package developped to work with the "NOAA Significant Earthquake Database".
National Geophysical Data Center / World Data Service (NGDC/WDS): Significant Earthquake Database. National Geophysical Data Center, NOAA. doi:10.7289/V5TD9V7K.
You can install this package from github using the following command:
library(devtools) devtools::install_github('llangevin/EQVT', build_vignettes = TRUE) library(EQVT)
eq_clean_data
and eq_location_clean
leaflet
) the earthquakes epicenters (LATITUDE/LONGITUDE) with the desired annotation (eg Date): eq_map
eq_create_label
ggplot2
package to visualize some of the information in the NOAA earthquakes dataset: geom_timeline
to visualize the times, the magnitudes and the number of deaths associated to earthquakes within certain countries.geom_timelinelabel
for adding annotations to the earthquake data and an option to subset the n_max largest earthquakes by magnitude.Download the data from the NOAA website, saved it to your working directory and transform it to a data frame using the read_delim
function:
library(readr) data <- readr::read_delim("signif.txt", delim = "\t")
Or you can use the file included in the package (September 2018):
filename <- system.file("extdata", "signif.txt", package="EQVT") library(readr) data <- readr::read_delim(filename, delim = "\t")
Before using the EQVT visualization tools, the data must be cleaned with the functions eq_clean_data
and eq_location_clean
.
clean_data <- eq_clean_data(data) clean_data <- eq_location_clean(clean_data)
To map the earthquakes epicenters in Mexico since 2000 and providing their dates in annotation use the eq_map
function:
clean_data %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% eq_map(annot_col = "DATE")
To have in annotation the Location, Total deaths, and Magnitude of the earthquakes, use the eq_create_label
function before the eq_map
function:
clean_data %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% dplyr::mutate(popup_text = eq_create_label(.)) %>% eq_map(annot_col = "popup_text")
To visualize the times, the magnitudes and the number of deaths associated to earthquakes within certain countries, use the geom_timeline
geom with the ggplot
function:
data %>% dplyr::filter(COUNTRY == c("MEXICO","USA") & lubridate::year(DATE) >= 2010) %>% ggplot(aes(x=DATE,y=COUNTRY,color=TOTAL_DEATHS,size=EQ_PRIMARY)) + geom_timeline(alpha=.5) + theme(legend.position="bottom", legend.box="horizontal", plot.title=element_text(hjust=0.5)) + ggtitle("Earthquakes Visualization Tool") + labs(size = "Richter scale value", color = "# deaths")
Use the geom_timelinelabel
geom for adding annotations to the earthquake data and an option to subset the n_max largest earthquakes by magnitude:
data %>% dplyr::filter(COUNTRY == c("MEXICO","USA") & lubridate::year(DATE) >= 2010) %>% ggplot(aes(x=DATE,y=COUNTRY,color=TOTAL_DEATHS,size=EQ_PRIMARY)) + geom_timeline(alpha=.5) + geom_timelinelabel(aes(label=LOCATION_NAME),n_max=3) + theme(legend.position="bottom", legend.box="horizontal", plot.title=element_text(hjust=0.5)) + ggtitle("Earthquakes Visualization Tool") + labs(size = "Richter scale value", color = "# deaths")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.