Created
September 2, 2016 08:53
-
-
Save expersso/2161c13fef177aa41c3c8aac1ec01fff to your computer and use it in GitHub Desktop.
Attempting to detect air pollution following SpaceX explosion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
library(ggmap) | |
library(ropenaq) | |
library(gridExtra) | |
# Get pollution data | |
df <- | |
aq_measurements( | |
country = "US", | |
city = "Deltona-Daytona+Beach-Ormond+Beach", | |
parameter = "pm25", | |
limit = 200 | |
) | |
p_pollution <- ggplot(df$results, aes(x = dateLocal, y = value)) + | |
geom_line() + | |
geom_point(alpha = 0.25, size = 1) + | |
geom_hline( | |
yintercept = mean(df$results$value), | |
linetype = "dashed", | |
size = 0.01, | |
color = "blue" | |
) + | |
geom_vline(xintercept = as.numeric(as.POSIXct("2016-09-01 09:00:00", "UTC")), | |
color = "red") + | |
scale_x_datetime(breaks = date_breaks("1 day"), labels = date_format("%m/%d")) + | |
theme_light() + | |
theme( | |
panel.grid.minor = element_blank(), | |
axis.title = element_text(size = 8), | |
axis.text = element_text(size = 7), | |
plot.caption = element_text(size = 8) | |
) + | |
labs( | |
x = "", | |
y = "Particulate matter 2.5 (μg/m3)\n", | |
title = "Air pollution following SpaceX explosion", | |
subtitle = "As measured in Daytona Beach", | |
caption = "Note: Dashed horizontal line shows sample mean. | |
Vertical red line shows approximate time of explosion (09:00 local time)." | |
) | |
# Get geo data | |
box_coords <- c(-80.7729003, 28.7798137) | |
map <- get_map(box_coords, zoom = 9, maptype = "satellite") | |
coords <- ggmap::geocode("Cape Canaveral Air Force Station") | |
coords <- coords %>% | |
add_row(lon = unique(df$results$longitude), | |
lat = unique(df$results$latitude)) %>% | |
mutate(location = c("Explosion\nlocation", "Measuring\nlocation")) | |
p_map <- ggmap(map) + | |
geom_point( | |
aes(x = lon, y = lat), | |
data = coords, | |
color = "red", | |
size = 3, | |
alpha = 0.4 | |
) + | |
geom_text( | |
aes(x = lon, y = lat, label = location), | |
data = coords, | |
color = "red", | |
hjust = 0, | |
fontface = "bold", | |
nudge_x = 0.1, | |
size = 3 | |
) + | |
theme_void() | |
grid.arrange(p_pollution, p_map, nrow = 1, widths = 2:1) |
Author
expersso
commented
Sep 2, 2016
@expersso even at KXMR with riem::riem_measures(station = "XMR", date_start = "2016-08-29", date_end = "2016-09-03")
there was nothing interesting. Somehow I'd have expected to see a spike or drop of a weather related paremeter but I know nothing about weather and maybe another airport would be more appropriate?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment