HES 505 Fall 2024: Session 4
Revisit the components of spatial data
Describe some of the key considerations for thinking about spatial data
Introduce the two primary R packages for spatial workflows
Learn to read and explore spatial objects in R
Let’s Kahoot!
https://create.kahoot.it/share/isdr-session-4/888711f4-50a3-4732-a707-cbf68d9ae9dc
RR PackagesMost basic form of spatial data
Need x (longitude) and y (latitude) as columns
Need to know your CRS
read_*** necessary to bring in the data
.shp is the shapefile itself.prj contains the CRS information.dbf contains the attributes.shx contains the indices for matching attributes to geometriesst_read and read_sf in the sf package will read shapefiles into R
read_sf leaves character vectors alone (often beneficial)
st_read can handle other datatypes (like geodatabases)
Returns slightly different classes
rast will read rasters using the terra package
Also used to create rasters from scratch
Returns SpatRaster object
Good idea to get to know your data before manipulating it
str, summary, nrow, ncol are good places to start
st_crs (for sf class objects) and crs (for SpatRaster objects)
We’ll practice a few of these now…
write_sf for sf objects; writeRaster for SpatRasters