task 2: Read the NYC postal areas in Shapefiles into sf objects.

zipcodes <- st_read("data/nyc/nyczipcodes.shp")
## Reading layer `nyczipcodes' from data source 
##   `C:\Users\student\OneDrive\.HUNTER\[4] SPRING 26\GTECH38502\work\R-spatial\data\nyc\nyczipcodes.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 178 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -74.25559 ymin: 40.49612 xmax: -73.70001 ymax: 40.91553
## Geodetic CRS:  WGS 84

task 3: Read and process the NYS health facilities spreadsheet data. Create sf objects from geographic coordinates.

healthfacilities<- read_csv("data/NYS_Health_Facility.csv")

healthfacilitiesclean <- healthfacilities %>% drop_na("Facility Longitude", "Facility Latitude")
healthfacilities_sf <- st_as_sf(healthfacilitiesclean, 
                               coords = c("Facility Longitude", "Facility Latitude"))

task 4: Read and process the NYS retail food stores data. Create sf objects from geographic coordinates for NYC.

retailfoodstores<- read_csv("data/nys_retail_food_store_xy.csv", show_col_types = FALSE, lazy = FALSE)

retailfoodstoresclean <- retailfoodstores %>% drop_na("X","Y")
retailfoodstores_sf <- st_as_sf(retailfoodstoresclean, 
                                coords = c("X", "Y"))

task 5: Use simple mapping method such as mapview with a basemap to verify the above datasets in terms of their geographic locations.

zipcodes %>% 
  mapview::mapview()
ggplot(data = healthfacilities_sf) +
  geom_sf(aes(color="red")) +
  coord_sf(xlim =  c(-80, -70), ylim = c(40, 45))

ggplot(data = retailfoodstores_sf) +
  geom_sf(aes(color="red")) +
  coord_sf(xlim =  c(-80, -70), ylim = c(40, 45))

task 6: Save the three sf objects in a RData file or in a single GeoPackage file/database.

save(zipcodes, healthfacilities_sf, retailfoodstores_sf, file = "week7lab.RData")