knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

noaa Package- Usage

This package is solely made to clean and analyze the data on earthquakes and obtain visual representations of the same over time and space.The goal is to present a timeline of eathquakes and a spatial overview of location specifics of each earthquake using their respective epicenter's latitude and longitude on a world map. Addition aesthetics like location name, date of occurrence etc can also be made to feature on the plots.Tweaking the data to some considerable extent, one can actually visualize the trends of earthquakes with respect time in different regions of the world.

library(noaa) # load the package

Load the Dataset

The source of the data is NOAA

data("eaq_data")

Data Summary.

Get a rough idea about the data set. For further details, check documentation of the loaded dataset.

names(eaq_data) #Features of the data set
head(eaq_data, 15) #snapshot of the dataset

The eq_clean_data function

data <- eq_clean_data(eaq_data)
head(data, 15)  # snapshot of the cleaned dataset
class(data$Latitude)
class(data$Longitude)
class(data$Date)

Creating a Timeline of Earthquakes

We will be using two sorts of timeline using geom_timeline and geom_timteline_label of ggplot. Both have similar construction except for the fact that the later can be used to annotate the points on the timeline.

library(magrittr)
library(ggplot2)

data <- eaq_data%>%
          eq_clean_data()%>%
          dplyr::filter(`Country` %in% c("MEXICO") & !(is.na(Mag))) 

ggplot(data = data, aes(x = Year, y = Country, size = Mag, colour = `Total Deaths`)) +
 geom_timeline(alpha = 0.3)
library(magrittr)

data <- eaq_data%>%
          eq_clean_data()%>%
          dplyr::filter(`Country` %in% c("MEXICO") & !(is.na(Mag))) 

ggplot(data = data, aes(x = Year, y = Country, size = Mag, colour = `Total Deaths`, label = `Location Name`)) + geom_timeline_label(alpha = 0.3)

The eq_create_label function

library (magrittr)
data <- eaq_data %>%
  eq_location_clean()%>%
  eq_create_label()

data[1:5]

Mapping the Earthquake locations on a World Map

eaq_data%>%
  eq_clean_data()%>%
  dplyr::filter(`Country` == "MEXICO" & lubridate::year(Date) >= 2000) %>%
  dplyr::mutate(popup_text = eq_create_label(.)) %>%
  eq_map(annot_col = "popup_text")
eaq_data%>%
  eq_clean_data()%>%
  dplyr::filter(`Country` == "MEXICO" & lubridate::year(Date) >= 2000) %>%
  eq_map(annot_col = "Date")


Noob-Programr/noaa documentation built on Dec. 17, 2021, 5:26 a.m.