Pier Lorenzo Paracchini, 17.06.2017
The purpose of this assignment is to use the knowledge acquired in the "Building Data Visualization Tools" course on a real challenge.
"Hurricanes can have asymmetrical wind fields, with much higher winds on one side of a storm compared to the other. Hurricane wind radii report how far winds of a certain intensity (e.g., 34, 50, or 64 knots) extended from a hurricane’s center, with separate values given for the northeast, northwest, southeast, and southwest quadrants of the storm. The 34 knot radius in the northeast quadrant, for example, reports the furthest distance from the center of the storm of any location that experienced 34-knot winds in that quadrant. This wind radii data provide a clearer picture of the storm structure than the simpler measurements of a storm’s position and maximum winds. For example, if a storm was moving very quickly, the forward motion of the storm might have contributed significantly to wind speeds to the right of the storm’s direction of forward motion, and wind radii might be much larger for the northeast quadrant of the storm than the northwest quadrant."
An example of the expected result can be found in the following image:
- Build a custom geom for ggplot2 that can be used to add the expected result for a single storm observation to a map
- Use the custom geom to map the expected result at one observation time for the Hurricane Ike which occured in Setptember 2008 (use an observatyion when the storm was near or over the United States).
-
Get the data for all storms in the Atlantic basin from 1988-2015
-
Clean the data
- Add a column for storm_id that combines storm name and year (unique identifier). Note that the same storm name can be used in different years
- Format the longitude to ensure that it is numeric and has negative values for locations in the Western emisphere
- Format and combine columns describing date and time to create a single variable with the date and time for each observation
- Convert the data to a long format with separate rows for each of the three wind speed (34 knots, 50 knots and 64 knots)
-
Subset the specific hurricane under interest, Hurricane Ike and get a single observation time for that hurricane
-
Write the code for the custom geom named geam_hurricane that plots the expected graph for a single hurricane observation in time
ggplot(data = katrina) +
geom_hurricane(aes(x = longitude, y = latitude,
r_ne = ne, r_se = se, r_nw = nw, r_sw = sw,
fill = wind_speed, color = wind_speed)) +
scale_color_manual(name = "Wind speed (kts)",
values = c("red", "orange", "yellow")) +
scale_fill_manual(name = "Wind speed (kts)",
values = c("red", "orange", "yellow"))
- Test to ensure that you can use the geom to add a hurricane wind radii chart to a base map.
map_data <- get_map("Louisiana", zoom = 6, maptype = "toner-background")
base_map <- ggmap(map_data, extent = "device")
base_map +
geom_hurricane(data = katrina, aes(x = longitude, y = latitude,
r_ne = ne, r_se = se,
r_nw = nw, r_sw = sw,
fill = wind_speed,
color = wind_speed)) +
scale_color_manual(name = "Wind speed (kts)",
values = c("red", "orange", "yellow")) +
scale_fill_manual(name = "Wind speed (kts)",
values = c("red", "orange", "yellow"))
The data, these wind radii, are available for Atlantic basin tropical storms since 1988 through the Extended Best Tract dataset, available here. A copy of the raw data, provided for the assignment, can be found in the ebtrk_atlc_1988_2015.txt file in the data folder of the repository.
From the documentation on line ..
'There is one line of data for each date and time period (00, 06, 12 or 18 UTC) of each storm (see sample line listed below). The information is given in the following order: Storm identification number, storm name, month, day, time, year, latitude (deg N), longitude (deg W), maximum wind speed (kt), minimum central pressure (hPa), radius of maximum wind speed (nm), eye diameter (nm), pressure of the outer closed isobar (hPa), radius of the outer closed isobar (nm), radii (nm) of 34 kt wind to the NE, SE, SW and NW of the storm center, radii (nm) of 50 kt wind to the NE, SE, SW and NW, radii (nm) of 64 kt wind to the NE, SE, SW, NW, and a storm type code. This code is either * for a tropical system (tropical depression, tropical storm, or hurricane), W for tropical wave, D for a tropical disturbance, S for a subtropical storm, E for an extra-tropical storm, or L for remnant low. The last record is the distance to the nearest major landmass (km), where the island of Trinidad is the smallest area considered to be land. Negative values indicate the storm center is over land. '
The details, and relevant code, around the cleaning of the data can be found in here.
A storm observation, e.g. KATRINA hurricane on 2005-08-09 at 12:00:00, in the cleaned data contains the following information
## storm_id date latitude longitude ne se sw nw wind_speed
## 1 KATRINA-2005 2005-08-29 12:00:00 29.5 -89.6 200 200 150 100 34
## 2 KATRINA-2005 2005-08-29 12:00:00 29.5 -89.6 120 120 75 75 50
## 3 KATRINA-2005 2005-08-29 12:00:00 29.5 -89.6 90 90 60 60 64
#Loading the cleaned data
data_hurricane <- readr::read_csv(file = "./data/ebtrk_atlc_1988_2015.cleaned.txt")
data_hurricane$wind_speed <- as.factor(data_hurricane$wind_speed)The experiments done in order to understand how to build custom geom in ggplot2 can be found here. The geom is implemented in the geom-hurricane.R file, while the test that can be used to test its usage can be found in test-geom-hurricane.R file.
An example of a map that shows the wind radii for a single observation time for Hurricane Ike can be seen next
library(magrittr)
source("./geom-hurricane.R")
#get the storm observation from cleaned data for the hurricane IKE
storm_observation_ike <- data_hurricane[data_hurricane$storm_id == "IKE-2008" &
data_hurricane$date == lubridate::ymd_hms("2008-09-11 18:00:00"),]
#Plot the map showing the wind radii for the selected storm observation
map_plot <- ggmap::get_map("Lousiana", zoom = 5, maptype = "toner-background")
map_plot %>%
ggmap::ggmap(extent = "device") +
geom_hurricane(data = storm_observation_ike,
ggplot2::aes(x = longitude, y = latitude,
r_ne = ne, r_se = se, r_nw = nw, r_sw = sw,
color = wind_speed, fill = wind_speed),scale_radii = 0.9) +
ggplot2::scale_color_manual(name = "Wind speed (kts)",
values = c("red", "orange", "yellow")) +
ggplot2::scale_fill_manual(name = "Wind speed (kts)",
values = c("red", "orange", "yellow"))"Building New Graphical Elements" from "Mastering Software Development in R" by Roger D. Peng, Sean Kross, and Brooke Anderson
"Extending ggplot2" Vignette from the ggplot2 package
"Introduction to the geosphere package" Vignette from the geosphere package

