Week 09 Assignment Task Overview

  1. Plot at least two high-quality static maps with one using the COVID-19 data and one using a related factor. You can use either plot method for sf or ggplot method.
  2. Use ggplot2 and other ggplot-compatible packages to create a multi-map figure illustrating the possible relationship between COVID-19 confirmed cases or rate and another factor (e.g., the number of nursing homes, number of food stores, neighborhood racial composition, elderly population, etc.). The maps should be put side by side on one single page. Add graticule to at least one of those maps and label some of the feature on the map where applicable and appropriate.
  3. Create a web-based interactive map for COIVD-19 data using tmap, mapview, or leaflet package and save it as a HTML file.

Task 1:

Task 2:

Use ggplot2 and other ggplot-compatible packages to create a multi-map figure illustrating the possible relationship between COVID-19 confirmed cases or rate and another factor (e.g., the number of nursing homes, number of food stores, neighborhood racial composition, elderly population, etc.). The maps should be put side by side on one single page. Add graticule to at least one of those maps and label some of the feature on the map where applicable and appropriate.

covidCases_map <- ggplot(covidBYzip) +
  geom_sf(aes(fill = COVID_CASE_COUNT)) +
  scale_fill_viridis_c(name = 'No. of Cases') +
  ggtitle("Number of COVID-19 Cases by Zip Code") +
  labs(x='Longitude', y='Latitude') +
  theme_minimal() +
  theme(legend.position = "bottom")+
  coord_sf(crs = st_crs(4326))

elderlyPop_map <- ggplot(popData_nyc) +
  geom_sf(aes(fill = elderlyPop)) +
  scale_fill_viridis_c(name = 'No. of People') +
  ggtitle("Population Age 65+ by Zip Code") +
  labs(x='Longitude', y='Latitude') +
  theme_minimal() +
  theme(legend.position = "bottom")+
  coord_sf(crs = st_crs(4326))

ggarrange(covidCases_map, elderlyPop_map, nrow = 1, ncol = 2)

Task 3:

Create a web-based interactive map for COIVD-19 data using tmap, mapview, or leaflet package and save it as a HTML file.

Percent Positivity Rate of COVID-19 Tests by Zip Code; April 23, 2020

pal_perPos <- colorQuantile("Reds", 
                        domain = c(min(covidBYzip$PERCENT_POSITIVE, na.rm = T), max(covidBYzip$PERCENT_POSITIVE, na.rm = T)),
                        alpha = TRUE)

htmlMap <- leaflet(covidBYzip) %>%
          addPolygons(
                stroke = TRUE, # show the polygon boundary
                fillOpacity = 0.8,
                fillColor = ~pal_perPos(PERCENT_POSITIVE),
                color = 'grey', # color of the boundary
                weight = 1, # width of the boundary
                label = paste(covidBYzip$PERCENT_POSITIVE),
                group = "Percent Positive") %>%  
              addTiles(group = "OSM")

htmlMap
saveWidget(htmlMap, "NYC_interactive_COVID_map.html")