eq_map: Earthquakes Data in an Interactive Map.

Description Usage Arguments Value Note Examples

View source: R/eq_map.R

Description

The function eq_map() that takes an argument data containing the filtered data frame with earthquakes to visualize. 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. The user should be able to choose which column is used for the annotation in the pop-up with a function argument named annot_col. Each earthquake should be shown with a circle, and the radius of the circle should be proportional to the earthquake's magnitude (EQ_PRIMARY).

The Earthquakes will be mapped centered with their latitude and longitude "epicenter". The epicenter is annotated based on an annot_col which the user can specify. In addition, if the user specifies "popup_text" then a call to eq_create_label generates the appropriate text for the popup.

Usage

1
eq_map(eq_data_clean = NULL, annot_col = "DATE")

Arguments

eq_data_clean

the clean earthquake data in a tbl_df object.

annot_col

a column name in the tbl_df object to be used for annotation.

Value

an interactive leaflet map.

Note

If an invalid column name is provided, the function provides a warning and uses the LOCATION_NAME column as the annotation column.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
filename <- system.file("extdata", "signif.txt", package = "earthquakes")
library(readr)
eq_data_raw <- readr::read_delim(file = filename, delim = "\t")
eq_data <- eq_clean_data(eq_raw = eq_data_raw)
library(dplyr)
library(lubridate)
library(leaflet)
eq_data %>%
    filter(COUNTRY %in% "ITALY" &
               lubridate::year(DATE) >= 2000) -> eq_data_sample

eq_data_sample %>%
    eq_clean_data() %>%
    filter(COUNTRY %in% "ITALY" & lubridate::year(DATE) >= 2000) %>%
    eq_map(annot_col = "DATE")

## End(Not run)

raggichr/earthquakes documentation built on June 25, 2020, 5:45 p.m.