Following up from my kernel on exploring the NTSB air accident data, where US aircraft accidents causing more than one fatality was explored, I wanted to also visualize the data in a meaningful way that can help an administrator understand the historic accident from the accident distribution within the US.
While preparing for this kernel, I wanted to use only static spatial maps (added interactive map at the end), and wanted to use the engineered features to make discernible visualization from the data. Even though the data visualization were trimmed only for the 48 contiguous states, because of the high number of accidents over the year, the visual looked just like polka-dot, when plotted over the US map, more or less evenly distributed. Other than dense dots in certain parts of the US in some states, I didn’t find plain relocation plot was that much help in communicating historical accident trends or distribution.
# Use quick plot
usmap <- qmap(location = "us",
zoom = 4 ,
color = "bw",
maptype = "terrain"
)
# Apply the contour
gg1 <- usmap +
stat_density2d(aes( x = lon,
y = lat,
fill = ..level..,
alpha = ..level..),
bins = 5,
geom = "polygon",
show.legend = "FALSE",
data = na.omit(df)) +
scale_fill_gradient(low = "dodgerblue", high = "darkblue") +
theme_gdocs()
# Add anotation
gg1 <- gg1 + labs(title = "US aircraft accident Spatial distribution contour plot.",
subtitle = "The 48 contiguous states air accident distribution for accident causing\n more than one fatality from 1980-2016.",
caption = "Data Source: NTSB\n Credit: R packages ggmap/ggplot2; Map: googlemap")# terrain
gg <- usmap +
stat_density2d(aes(x = lon,
y = lat,
fill = ..level..,
alpha = ..level..),
bins = 5,
geom = "polygon",
show.legend = "FALSE",
data = na.omit(df)) +
scale_fill_gradient(low = "dodgerblue", high = "darkblue") +
theme_gdocs() +
facet_wrap(~ month)
# Add anotation
gg <- gg + labs(title = "US Monthly facetted aircraft fatality contour plot from 1980-2016.",
subtitle = "The spatial distribution of US air accident for accident causing\n more than one fatality from 1980-2016.",
caption = "Data Source: NTSB\n Credit: R packages ggmap/ggplot2; Map: googlemap")# toner-labels
gg2 <- usmap + geom_point(aes(x = lon, y = lat, colour = state), size = 1, data = na.omit(df)) +
theme_gdocs() +
theme(legend.position = "none")
# Add anotation
gg2 <- gg2 + labs(title = "US aircraft accident static gelocatoin plot.",
subtitle = "The 48 contiguous states air accident distribution, colored by states, \nfor accident causing more than one fatality from 1980-2016.",
caption = "Data Source: NTSB\n Credit: R packages ggmap/ggplot2; Map: googlemap")m <- leaflet(na.omit(df) ) %>% setView(-93.65, 42.025, zoom = 4)
m <- m %>% addProviderTiles("CartoDB.DarkMatter") %>%
addCircles(~lon,
~lat,
popup = ~ city,
color = "greenyellow",
weight = 1,
fillOpacity = 1)
mAt the end, blending spatial contour map, specific colors and faceted accident distribution by month, I think, tells a better story of aircraft accident history in US. It goes to show, certain types of months favor accidents in certain parts of the country.
This could be due to seasonal weather conditions or perhaps there are frequent flights due to events in the calendar in that time of the year. Or it could also be just coincidence. The point is that the visualization summarized over 36 years of aircraft accidents in the continental US, and some knowledge can be gained from the visual that can be applied to flight safety procedures.
Pckages and software used for this kernel are:
**Notes:**
i) The static maps were plotted with ggmap packages, “a collection of functions to visualize spatial data and models on top of static maps from various online sources.” For the tile, I used Google Maps. ii) ggplot2 version 2.2.1 was used for annotation and plotting the quadrant graph that shows accident trends. iii) For the interactive plot, leaflet a Javascript library.
—EOF