Get the data required for this vignette
# Compressed folder with files from rassta’s installation folder <- system.file("exdat/wasoil.zip", package = "rassta") wasoil # Directory for temporary files <- tempdir() o # Copy compressed folder to directory for temporary files file.copy(from = wasoil, to = o) #>  TRUE # Extract files to subfolder <- paste(o, "/rassta", sep = "") d unzip(paste(o, "/wasoil.zip", sep = ""), exdir = d)
The landscape similarity is a relative measurement of the correspondence between any XY location in geographic space and the landscape configuration represented by a given stratification unit. The spatial signature represents a second-level landscape correspondence metric, and it is calculated through the pixel-wise aggregation of the spatial signatures associated with a stratification unit. Each stratification unit has a set of associated spatial signatures because the stratification units are the result of the spatial intersection of multiple classification units, which in turn have a corresponding spatial signature.
The code below demonstrates the calculation of landscape similarity layers for the stratification units using similarity(). The function similarity() requires a single-layer SpatRaster object representing stratification units, and a multi-layer SpatRaster object with the spatial signatures of classification units from multiple landscape factors.
# Load rassta and terra packages library(rassta) library(terra) # Multi-layer SpatRaster with spatial signatures of classification units <- rast(list.files(d, pattern = "climate_", full.names = TRUE)) # For climatic units clim.sig <- rast(list.files(d, pattern = "material_", full.names = TRUE)) # For material units mat.sig <- rast(list.files(d, pattern = "terrain_", full.names = TRUE)) # For terrain units terr.sig # Single-layer SpatRaster of stratification units <- rast(paste(d, "/su.tif", sep = "")) su # Landscape similarity to stratification units <- similarity(su.rast = su, sig.rast = c(clim.sig, mat.sig, terr.sig), su.ls su.code = list(climate = c(1, 1), material = c(2, 2), terrain = c(3, 3) ) )# Plot landscape similarity to stratification unit '111' and its spatial signatures plot(c(su.ls$landsim[], clim.sig[], mat.sig[], terr.sig[]), col = hcl.colors(100, "Oslo", rev = TRUE), nc = 2, mar = c(1.5, 1.5, 1.5, 3.5) )
An important argument of similarity() is su_code. This (nested) list should indicate the names of the landscape factors/factor scales used to create the stratification units, and the position (start, end) of their corresponding classification units’ ID in the numeric code. The code below provides comments to aid in understanding the argument su_code.
# Consider the following nested list: <- list(climate = c(1, 1), material = c(2, 2), terrain = c(3, 3)) su.code # The stratification units are composed of classification units from three landscape factors names(su.code) #>  "climate" "material" "terrain" # For climate, the classification units are represented by the first digit in the numeric code $climate su.code#>  1 1 # For material, the classification units are represented by the second digit in the numeric code $material su.code#>  2 2 # For terrain, the classification units are represented by the third digit in the numeric code $terrain su.code#>  3 3 # Thus, the numeric code of the stratification units 111 and 468 means: <- c(111, 468) su 1] # 'climate' = 1, 'material' = 1, and 'terrain' = 1 su[#>  111 2] # 'climate' = 4, 'material' = 6, and 'terrain' = 8 su[#>  468
Clean files from temporary directory
unlink(c(paste(o, "/wasoil.zip", sep = ""), d), recursive = TRUE)