Code
<- "hello, R markdown and RPubs!"
smpCode
cat(smpCode)
hello, R markdown and RPubs!
Update the title with your information. Make sure to include identification information so that we know it is your submission.
Also update the author name and date accordingly.
Check out the Source Code from the top-right corner </>Code
menu.
In the following R code chunk, load_packages
is the code chunk name. include=FALSE
suggests that the code chunk will run, but the code itself and its outputs will not be included in the rendered HTML. echo=TRUE
in the following code chunk suggests that the code and results from running the code will be included in the rendered HTML.
Don’t use a single chunk for the entire assignment. Break it into multiple chunks.
<- "hello, R markdown and RPubs!"
smpCode
cat(smpCode)
hello, R markdown and RPubs!
<- st_read('R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp') zip_codes
Reading layer `ZIP_CODE_040114' from data source
`C:\Users\wcornejo\Documents\assign7\assign7\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)
<- read.csv('R-Spatial_I_Lab/NYS_Health_Facility 3(in).csv')
health_facilities <- health_facilities[!is.na(health_facilities$Facility.Longitude), ]
hf_df <- hf_df[!is.na(hf_df$Facility.Latitude), ]
hf_df <- hf_df[!is.na(hf_df$Facility.Longitude), ]
hf_df <- hf_df[hf_df$Facility.Latitude != 0, ]
hf_df <- hf_df[hf_df$Facility.Longitude != 0, ]
hf_df <- st_as_sf(hf_df, coords = c("Facility.Longitude", "Facility.Latitude")) hf_sf
<- read.csv('R-Spatial_I_Lab/NYS_Retail_Food_Stores.csv')
retail_df <- read.csv('R-Spatial_I_Lab/nys_retail_food_store_xy.csv')
retail_df_xy <- retail_df_xy[!is.na(retail_df_xy$X),]
r_sf <- r_sf[!is.na(r_sf$Y),]
r_sf <- st_as_sf(r_sf, coords = c("X", "Y"))
r_sf #had to save with encoding utf-8 in vscode
plot(r_sf)
Warning: plotting the first 9 out of 16 attributes; use max.plot = 16 to plot
all
Warning in min(x): no non-missing arguments to min; returning Inf
Warning in max(x): no non-missing arguments to max; returning -Inf
#mapview() + mapview(hf_sf)
#mapview() + mapview(r_sf)
mapview() + mapview(zip_codes['POPULATION'])
save(zip_codes, zip_codes,
file = 'zip_codes_sf.RData')
save(hf_sf, health_facilities,
file = 'health_facilities.RData')
# Now a geopackage
st_write(r_sf,
dsn = 'retail_stores.gpkg',
layer='',
delete_layer = TRUE)
writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
Deleting layer `' failed
Writing layer `' to data source `retail_stores.gpkg' using driver `GPKG'
Writing 23972 features with 16 fields and geometry type Point.