require(terra)
p <- system.file("exdat", package = "rassta")
# Multi-layer SpatRast with classification units (Cus)
## Three sets (i.e., landscape factors): geology, climate and topography
fcu <- list.files(path = p,
pattern = "geology.tif|climate.tif|topography.tif",
full.names = TRUE
)
cu <- terra::rast(fcu)
# Stratification units (SUs)
su <- strata(cu.rast = cu)
# Plot the stratification units
if(interactive()){plot(su$su.rast, type = "classes")}
#
# Note code structure from SUs and corresponding values from CUs
z <- c(su$su.rast, cu)[46,61] # Example of one cell (row = 45, column = 45)
su$code.mult # Multipliers
z[c("SU", names(su$code.mult))] # Code structure
# Note what happens when some landscape factors have cell values greater...
#... than 1 digit (i.e., more than 9 distinct classification units)
cu <- c(cu[[1]], cu[[2]]^4, cu[[3]]^2)
su <- strata(cu.rast = cu)
su$code.mult
c(su$su.rast, cu[[names(su$code.mult)]])[46,61]
Run the code above in your browser using DataLab