require(terra)
p <- system.file("exdat", package = "rassta")
# Single-layer SpatRaster of stratification units
fsu <- list.files(path = p, pattern = "strata.tif", full.names = TRUE)
su <- terra::rast(fsu)
# Observations with response values.
## For this example, soil organic carbon (SOC) collected at 15 cm soil depth
fob <- list.files(path = p, pattern = "soc.shp", full.names = TRUE)
ob <- terra::vect(fob)
# Column indices for ID and measured response value
id <- 1
re <- 2
# Multi-layer SpatRaster of landscape similarities
fls <- list.files(path = p, pattern = "su_", full.names = TRUE)
ls <- terra::rast(fls)
# Selection of representative response observations for stratification units
ro <- observation(su.rast = su, obs = ob, col.id = id, col.resp = re,
ls.rast = ls
)
# Plot representative observations
if(interactive()){plot(su, type = "classes",
fun = function() points(ro$su_repobs.sp)
)}
Run the code above in your browser using DataLab