Task 1:
covid19 <- read_csv("C:/Users/rsaya/Downloads/GEOG 39300/Section_3/Lecture_8/Data/tests-by-zcta_2021_04_23.csv",
show_col_types = FALSE) %>%
clean_names()
nyc_zip <- st_read(dsn = 'C:/Users/rsaya/Downloads/GEOG 39300/Section_3/Lecture_7/Data/nyc/ny_data.gpkg',
layer = 'nyc_zip') %>%
clean_names()
## Reading layer `nyc_zip' from data source
## `C:\Users\rsaya\Downloads\GEOG 39300\Section_3\Lecture_7\Data\nyc\ny_data.gpkg'
## using driver `GPKG'
## Simple feature collection with 263 features and 12 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 913129 ymin: 120020.9 xmax: 1067494 ymax: 272710.9
## Projected CRS: NAD83 / New York Long Island (ftUS)
nyc_zip <- st_transform(nyc_zip, crs = 4326)
covid19_sf_merged <- base::merge(nyc_zip, covid19, by.x = "zipcode",
by.y = "modified_zcta")
mapview(covid19_sf_merged, zcol='total_covid_tests', layer.name='Total Covid Test')
Task 2:
nyc_food_sf <- st_read(dsn = 'C:/Users/rsaya/Downloads/GEOG 39300/Section_3/Lecture_7/Data/nyc/ny_data.gpkg',
layer = 'nyc_retail')
## Reading layer `nyc_retail' from data source
## `C:\Users\rsaya\Downloads\GEOG 39300\Section_3\Lecture_7\Data\nyc\ny_data.gpkg'
## using driver `GPKG'
## Simple feature collection with 11300 features and 16 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -74.2484 ymin: 40.50782 xmax: -73.67061 ymax: 40.91008
## Geodetic CRS: WGS 84
nyc_food_retail <- nyc_food_sf %>%
dplyr::filter(stringr::str_detect(establishment_type, '[AJD]')) %>%
sf::st_join(nyc_zip, ., join = st_contains) %>%
group_by(zipcode) %>%
summarize(food_location = n ())
mapview(nyc_food_retail, zcol='food_location', layer.name= 'NYC Food Stores')