Skip to content

Instantly share code, notes, and snippets.

@dKvale
Created September 20, 2018 00:08
Show Gist options
  • Select an option

  • Save dKvale/8ed4e9df4fae940182dccf992f88b33f to your computer and use it in GitHub Desktop.

Select an option

Save dKvale/8ed4e9df4fae940182dccf992f88b33f to your computer and use it in GitHub Desktop.
library(albersusa) # devtools::install_github("hrbrmstr/albersusa")
library(ggalt) # devtools::install_github("hrbrmstr/ggalt")
library(hrbrthemes) # devtools::install_github("hrbrmstr/hrbrthemes")
library(rrricanes)
library(tidyverse)
library(ggrepel)
storms <- get_storms()
strength <-
c(
"Subtropical Depression" = "#31688E",
"Tropical Depression" = "#26828E",
"Tropical Storm" = "#6DCD59",
"Hurricane" = "#FDE725",
"Post-Tropical Cyclone" = "#482878",
"Remnants Of" = "#440154"
) # deliberate viridis-colormap selections
# Get storm tracks
mutate(storms, track = map(Link, get_storm_data, products="fstadv")) %>%
unnest(track) %>%
unnest(track) %>%
mutate(Status = factor(Status, levels=names(strength))) %>%
arrange(Date) ->
tracks
# Get world map
wrld <- tbl_df(map_data("world"))
# Plot black map
ggplot() +
geom_cartogram(
data = wrld,
map = wrld,
aes(long, lat, map_id = region),
fill = alpha("lightgray", 1/10),
color = alpha("white", 1/2),
size = 0.065
) +
geom_path(
data = tracks, aes(Lon, Lat, group = Name, color = Status),
size = 1, alpha=1/2
) +
#geom_text_repel(
# data = tracks %>% group_by(Name) %>% sample_n(1),
# aes(Lon, Lat, label = Name),
# color = alpha("white", 1/2), size = 3
#) +
coord_proj(us_aeqd_proj) + # swap these two lines for globe/zoom
#coord_proj(us_aeqd_proj, xlim = c(-145, -30), ylim = c(5,60)) +
scale_color_manual(name = NULL, values = strength) +
labs(
x = NULL, y = NULL,
title = "2018 NOAA Named Tropical Storms (Atlantic/East Pacific)"
) +
theme_ft_rc(grid = "") +
theme(axis.text = element_blank()) +
theme(legend.position = "bottom")
##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment