library(earthquakevisualization) library(dplyr) library(readr) library(ggplot2) library(leaflet) library(lubridate) library(tidyr)
This vignette describes the functions and use cases of the NOAA package. The NOAA package is centered around a dataset obtained from the U.S. National Oceanographic and Atmospheric Administration (NOAA) on significant earthquakes around the world.
This package has functions for processing/filtering and visualization of the earthquake dataset.
The functions for processing and filtering of the earthquake dataset include:
The functions for visualization of the earthquake dataset include:
This function takes as input a data.frame of the entire significant earthquake data, cleans the LOCATION_NAME column by stripping out the country name (including the colon) and converts names to title case (as opposed to all caps).
NOAA_url = "https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt" data <- suppressMessages({readr::read_delim(NOAA_url, delim = "\t", progress = FALSE)}) print(head(data$LOCATION_NAME)) clean_data = eq_location_clean(data) print(head(clean_data$LOCATION_NAME))
This function reads tab-delimited file of the entire significant earthquake data available at NOAA_url from U.S. National Oceanographic and Atmospheric Administration (NOAA) database. After reading the columns YEAR, MONTH and DAY are merged into column named DATE, which contains Date class entries.
NOAA_clean_data = eq_clean_data("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt") print(NOAA_clean_data)
This function filters the earthquake data - generated by U.S. National Oceanographic and Atmospheric Administration (NOAA) database - based on specified minimum date, maximum date and country.
NOAA_clean_data = eq_clean_data("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt") NOAA_filtered = filter_date_and_country(NOAA_clean_data, xmindate = "1999-01-01", xmaxdate = "2017-12-31", country = c("CHINA", "USA")) print(NOAA_filtered %>% select(DATE, COUNTRY))
This function takes the earthquake dataset - generated by U.S. National Oceanographic and Atmospheric Administration (NOAA) database - as an argument and creates an HTML label that can be used as the annotation text in the leaflet map.
NOAA_clean_data = eq_clean_data("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt") NOAA_clean_data %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% dplyr::mutate(popup_text = eq_create_label(.)) %>% select(popup_text) %>% print(.) #Note: text is created as HTML label
This function plots a time line of earthquakes from generated by U.S. National Oceanographic and Atmospheric Administration (NOAA) database.
NOAA_clean_data = eq_clean_data("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt") geom_timeline(NOAA_clean_data, xmindate = "1999-01-01", xmaxdate = "2017-12-31", country = c("CHINA", "USA", "JAPAN"))
This function plots a time line of earthquakes from U.S. National Oceanographic and Atmospheric Administration (NOAA) database. This geom adds a vertical line to each data point with a text annotation (e.g. the location of the earthquake) attached to each line.
NOAA_clean_data = eq_clean_data("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt") geom_timeline_label(NOAA_clean_data, xmindate = "1999-01-01", xmaxdate = "2017-12-31", country = c("CHINA", "USA"), n_max = 7.2)
This function plots earthquake data generated by U.S. National Oceanographic and Atmospheric Administration (NOAA) on the map. The function maps the epicenters (LATITUDE/LONGITUDE) and annotates each point with in pop up window containing annotation data stored in a column of the data frame.
NOAA_clean_data = eq_clean_data("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt") NOAA_clean_data %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% eq_map(annot_col = "DATE") NOAA_clean_data %>% dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>% dplyr::mutate(popup_text = eq_create_label(.)) %>% eq_map(annot_col = "popup_text")
Unauthorized copying of this file, via any medium is strictly prohibited. The code/project cannot be copied and/or distributed without the express permission of Ganna Androsova.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.