1. Set up project
2. Read NYC postal areas in Shapefile to sf objects
nyc_zip <- st_read("R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp")
## Reading layer `ZIP_CODE_040114' from data source
## `/Users/jorgesoldevila/Desktop/OneDrive - Hunter - CUNY/R Data Analysis and Visualization/Section_10/R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp'
## using driver `ESRI Shapefile'
## 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)
3. Read and process the NYC public health services spreadsheet data
health_services_df <- read_csv("./R-Spatial_I_Lab/NYS_Health_Facility.csv") %>%
drop_na(`Facility Longitude`,
`Facility Latitude`) %>% filter(`Facility Longitude`!=0)
health_services_sf <- st_as_sf(health_services_df,
coords = c("Facility Longitude", "Facility Latitude")) %>%
st_set_crs(4326)
4. Read and process the NYS retail food stores data
food_stores_df <- read.csv("./R-Spatial_I_Lab/NYS_Retail_Food_Stores.csv")
food_stores_df %>%
tidyr::separate(Location, c(NA, "Both", NA), sep = "(\\(|\\))") %>%
tidyr::separate(Both, c("Lat", "Long"), sep = ",") %>%
dplyr::mutate(Lat = as.numeric(Lat), Long = as.numeric(Long)) %>%
tidyr::drop_na(Lat, Long) %>%
sf::st_as_sf(coords = c('Long', 'Lat')) %>%
st_set_crs(4326) -> food_stores_sf
5. Use simple mapping method
mapview(nyc_zip)
mapview(health_services_sf)