Developing Data Products: Week 2 Assignment

For the assignemt I’ve downloaded and pre-processed the locations of air quality monitors in United States. Their location is shown on the map by type, multiple type sensors have a separate category. The map siplay uses the “clustered markers” feature of Leaflet.

# Download data
if(!file.exists("annual_conc_by_monitor_2017.csv")) {
  if(!file.exists("annual_conc_by_monitor_2017.zip")) {
      download.file("https://aqs.epa.gov/aqsweb/airdata/annual_conc_by_monitor_2017.zip",
                destfile = "annual_conc_by_monitor_2017.zip")
  }
  unzip("annual_conc_by_monitor_2017.zip")
}

# Process selected monitor data
library(dplyr)
anc_sub <- tbl_df(read.csv("annual_conc_by_monitor_2017.csv")) %>% 
  filter(Parameter.Name %in% c("PM2.5 - Local Conditions", "Ozone", "Sulfur dioxide")) %>%
  select(Latitude,Longitude,Parameter.Name) %>% 
  distinct() %>% 
  group_by(Latitude, Longitude) %>%
  summarise(Monitored.params = paste(Parameter.Name, collapse = ", ")) %>%
  mutate(Color = "none") %>%
  mutate(Color = ifelse(Monitored.params == "PM2.5 - Local Conditions", "red", 
                        ifelse(Monitored.params == "Sulfur dioxide", "yellow",
                               ifelse(Monitored.params == "Ozone", "blue", "orange"))))

Leaflet map of air quality monitors