Set up a R project for the R-Spatial section.
setwd("~/Data Analysis and Viz/Week7/Data/R-Spatial_I_Lab")
nyc_zips <- st_read("C:/Users/Zack/Documents/Data Analysis and Viz/Week7/Data/R-Spatial_I_Lab/ZIP_CODE_040114.shp")
## Reading layer `ZIP_CODE_040114' from data source
## `C:\Users\Zack\Documents\Data Analysis and Viz\Week7\Data\R-Spatial_I_Lab\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)
summary(nyc_zips)
## ZIPCODE BLDGZIP PO_NAME POPULATION
## Length:263 Length:263 Length:263 Min. : 0.0
## Class :character Class :character Class :character 1st Qu.: 49.5
## Mode :character Mode :character Mode :character Median : 27985.0
## Mean : 31933.9
## 3rd Qu.: 54445.0
## Max. :109069.0
## AREA STATE COUNTY ST_FIPS
## Min. : 3155 Length:263 Length:263 Length:263
## 1st Qu.: 964323 Class :character Class :character Class :character
## Median : 21927545 Mode :character Mode :character Mode :character
## Mean : 31816554
## 3rd Qu.: 45935567
## Max. :473985727
## CTY_FIPS URL SHAPE_AREA SHAPE_LEN
## Length:263 Length:263 Min. :0 Min. :0
## Class :character Class :character 1st Qu.:0 1st Qu.:0
## Mode :character Mode :character Median :0 Median :0
## Mean :0 Mean :0
## 3rd Qu.:0 3rd Qu.:0
## Max. :0 Max. :0
## geometry
## POLYGON :263
## epsg:2263 : 0
## +proj=lcc ...: 0
##
##
##
Task 2: Read Health Facilities and Convert to sf
health_data <- read_csv("C:/Users/Zack/Documents/Data Analysis and Viz/Week7/Data/R-Spatial_I_Lab/NYS_Health_Facility.csv")
# Convert to sf object
health_sf <- health_data %>%
filter(!is.na(`Facility Longitude`), !is.na(`Facility Latitude`)) %>%
st_as_sf(coords = c("Facility Longitude", "Facility Latitude"), crs = 4326)
mapview::mapview(health_sf)