# load packages
library(tidyverse)
library(maps)
library(ggplot2)
= read.csv("ibtracs.NA.list.v04r00.csv", stringsAsFactors = FALSE)
NA.basin = read.csv("ibtracs.EP.list.v04r00.csv", stringsAsFactors = FALSE)
EP.basin
# remove variable information
= NA.basin[-1, ]
NA.basin = EP.basin[-1, ]
EP.basin
# formatting some columns
$Season = as.numeric(NA.basin$SEASON)
NA.basin$Latitude = as.numeric(gsub("^ ", "", NA.basin$LAT))
NA.basin$Longitude = as.numeric(gsub("^ ", "", NA.basin$LON))
NA.basin$Wind.WMO. = as.numeric(gsub("^ ", "", NA.basin$WMO_WIND))
NA.basin
$Season = as.numeric(EP.basin$SEASON)
EP.basin$Latitude = as.numeric(gsub("^ ", "", EP.basin$LAT))
EP.basin$Longitude = as.numeric(gsub("^ ", "", EP.basin$LON))
EP.basin$Wind.WMO. = as.numeric(gsub("^ ", "", EP.basin$WMO_WIND))
EP.basin
# extract month for dataset NA.basin
= strsplit(NA.basin$ISO_TIME, " ")
time.date = unlist(lapply(time.date, function(x) x[1]))
iso.date = substr(iso.date, 6, 7)
iso.month $Month = factor(iso.month, labels = c(month.name))
NA.basin
# extract month for dataset EP.basin
= strsplit(EP.basin$ISO_TIME, " ")
time.date = unlist(lapply(time.date, function(x) x[1]))
iso.date = substr(iso.date, 6, 7)
iso.month #EP.basin$Month = factor(iso.month, labels = c(month.name)[-4])
$Month = factor(iso.month, labels = c(month.name))
EP.basin
# join data frames
= rbind(NA.basin, EP.basin) storms
’Visualizing Hurricane Paths
The Data
The data is freely available from the International Best Track Archive for Climate Stewardship (IBTrACS)[https://www.ncei.noaa.gov/products/international-best-track-archive] at the National Climatic Data Center website and can be downloaded in different formats.
Basins include: - NA - North Atlantic - EP - Eastern North Pacific - WP - Western North Pacific - NI - North Indian - SI - South Indian - SP - Southern Pacific - SA - South Atlantic
This project includes only North Atlantic and Eastern North Pacific.
Prepare the plot
Once we’ve cleaned and processed the data, the next step is to prepare the ingredients for plotting a map. For this example, I’m selecting hurricanes from 1999 to 2010, and removing unnamed storms:
# world map
= map_data("world")
wm
# select storms between 2000 and 2021
<- storms %>% filter(Season %in% c(2000:2021) & NAME != "NOT_NAMED")
substorms
# add and ID with name and season
$ID = as.factor(paste(substorms$NAME, substorms$SEASON, sep = "."))
substorms
# storm name as factor
$NAME = as.factor(substorms$NAME) substorms
Overall Hurricanes
Let’s plot the data with all the selected storms
= ggplot(substorms, aes(x = Longitude, y = Latitude, group = ID)) +
map1 geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group),
fill = "gray25", color = "gray10", size = 0.2) +
geom_path(data = substorms, aes(group = ID, color = Wind.WMO.), alpha = 0.5, size = 0.8) +
xlim(-138, -20) + ylim(3, 55) +
labs(x = "", y = "", color = "Wind \n(knots)") +
theme(panel.background = element_rect(fill = "gray10", color = "gray30"), axis.text = element_blank()) +
ggtitle("Hurricane Trajectories 2000 - 2021")
# show me the map
map1
Hurricanes by month
Let’s get a more interesting visualization by months
# with facet-wrap by Month
= ggplot(substorms, aes(x = Longitude, y = Latitude, group = ID)) +
map2 geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), fill = "gray25", color = "gray10", size = 0.2) +
geom_path(data = substorms, aes(group = ID, color = Wind.WMO.), size = 0.5) +
xlim(-138, -20) + ylim(3, 55) +
labs(x = "", y = "", color = "Wind \n(knots)") +
facet_wrap(~Month) +
# opts(title = "Hurricane Trajectories by Month (1999 - 2010)",
# panel.background = element_rect(fill = "gray10", color = "gray30"),
# axis.text.x = element_blank(), axis.text.y = element_blank(),
# axis.ticks = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank())
theme(panel.background = element_rect(fill = "gray10", color = "gray30"), axis.text = element_blank(),
axis.text.y = element_blank(), axis.ticks = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ggtitle("Hurricane Trajectories by Month (2000 - 2021)")
map2