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)
#> [1] TRUE
# Extract files to subfolder
<- paste(o, "/rassta", sep = "")
d unzip(paste(o, "/wasoil.zip", sep = ""), exdir = d)
The use of stratification units for sampling allows adequate representations of the feature space, improved modeling performance, and cost-efficient field work. Accordingly, rassta allows the stratified selection of observations from an existing sample and the selection of XY locations to create a new sample. The stratified sampling with rassta can include the landscape similarity layers. Accounting for the landscape similarity will ensure that the observation/location selected for a given stratification unit is the one which best reflects the landscape configuration represented by the unit. The use of landscape similarity layers in the sampling process results in a stratified, non-probability sample.
The selection of observations from an existing sample with rassta results in one observation per stratification unit in a set. This observation is termed the representative response observation. The representative response observation is assumed to best reflect the control that the landscape configuration represented by a stratification unit exerts on response phenomena. Currently, rassta allows to select a representative response observation for each stratification unit in a set based on the following methods:
The first two methods represent a stratified non-probability sampling, while the third method represents a stratified random sampling. Moreover, the first method is biased towards maximizing the representativeness of landscape configurations because it uses landscape similarity layers. The codes below demonstrate the selection of representative response observations with observation(). The observations will be selected from a sample of n = 195 based on the mls method.
# Load rassta and terra packages
library(rassta)
library(terra)
# Single-layer SpatRaster of stratification units
<- rast(paste(d, "/su.tif", sep = ""))
su # 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 # 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)
) )
# SpatVector with SOC observations for stratification units
<- vect(paste(d, "/soc.shp", sep = ""))
socobs # Representative SOC observation for each stratification unit
<- observation(su.rast = su, obs = socobs, col.id = 1, col.resp = 2,
su.obs method = "mls", ls.rast = su.ls$landsim
)# Information about sample and representative SOC observations
socobs#> class : SpatVector
#> geometry : points
#> dimensions : 195, 2 (geometries, attributes)
#> extent : 284252, 292532, 153471, 161811 (xmin, xmax, ymin, ymax)
#> source : soc.shp
#> coord. ref. : NAD83 / Washington South (EPSG:32149)
#> names : ID soc
#> type : <int> <num>
#> values : 1 6.603
#> 2 5.701
#> 3 5.594
$su_repobs.sp
su.obs#> class : SpatVector
#> geometry : points
#> dimensions : 56, 4 (geometries, attributes)
#> extent : 284252, 292532, 153651, 161811 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83 / Washington South (EPSG:32149)
#> names : ID soc SU land_sim
#> type : <int> <num> <int> <num>
#> values : 1 6.603 111 80.67
#> 6 5.443 112 85
#> 10 4.609 114 77.33
# Set graphics arrangement
par(mfrow = c(1,2))
# Plot stratification units and response observations
plot(su, type = "classes", col = hcl.colors(56, "spectral"), legend = FALSE,
mar = c(3, 2, 3, 1.5), main = paste("Soil Organic Carbon Observations"),
fun = function() c(points(socobs, pch = 21, bg = rgb(0,1,0,1)),
points(su.obs$su_repobs.sp, pch = 21, bg = rgb(0,0,1,1))
)
)# Set new graphics arrangement
par(mar = c(2, 1.5, 1.5, 1.5))
# Plot histogram of soil organic carbon values from all observations
hist(socobs$soc, 4, col = rgb(0,1,0,0.8), main = "Soil Organic Carbon (%)", xlab = "")
# Plot histogram of soil organic carbon values from representative observations
hist(su.obs$su_repobs.sp$soc, 4, add = T, col = rgb(0,0,1,0.9))
# Add legend
legend("topright", legend = c("Sample", "Representative Observations"),
col = c(rgb(0,1,0,0.8), rgb(0,0,1,0.9)), pch = 20, bty = "n", pt.cex = 2,
cex = 0.6, text.col = "black", horiz = F, inset = c(0, 0.05)
)
For those cases when a sample with observations of a response phenomenon is not available, rassta allows to define XY locations that can be used to establish field sampling campaigns. The selection of representative sampling locations is performed for each stratification unit in a set, and it utilizes the landscape similarity layers to define the XY locations. Currently, rassta allows to select representative sampling locations based on two approaches:
buffer: selects the XY location(s) within spatially contiguous areas with landscape similarity values above a user-defined threshold.
absolute: selects the XY location(s) with the n highest landscape similarity values.
The code below demonstrates the selection of representative sampling locations with the function locations(), based on the buffer method.
# Representative sampling location and its buffer area for each stratification unit
<- locations(ls.rast = su.ls$landsim, su.rast = su, method = "buffer")
su.samp # Information about representative sampling locations and corresponding buffer areas
$locations
su.samp#> class : SpatVector
#> geometry : points
#> dimensions : 90, 2 (geometries, attributes)
#> extent : 284072, 292532, 153351, 161841 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83 / Washington South (EPSG:32149)
#> names : SU land_sim
#> type : <num> <num>
#> values : 1 66.33
#> 1 66.33
#> 1 69.67
$buffers
su.samp#> class : SpatVector
#> geometry : polygons
#> dimensions : 56, 2 (geometries, attributes)
#> extent : 284027, 292547, 153336, 161856 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83 / Washington South (EPSG:32149)
#> names : SU area
#> type : <num> <num>
#> values : 111 9.182e+04
#> 112 1.026e+05
#> 113 1.206e+05
The spatial distribution of representative sampling locations and the statistical distribution of landscape similarity can be plotted as demonstrated in the code below.
# Set graphics arrangement
par(mfrow = c(1,2))
# Plot stratification units, representative sampling locations and buffer areas
plot(su, type = "classes", col = hcl.colors(56, "spectral"), legend = FALSE,
mar = c(3, 2, 3, 1.5), main = "Representative Sampling Locations",
fun = function() c(polys(su.samp$buffers, col = rgb(0,1,0,0.5)),
points(su.samp$locations, pch = 21, col = "black",
bg = rgb(0,1,0,1)
)
)
)# Set new graphics arrangement
par(mar = c(2, 1.5, 1.5, 1.5))
# Plot histogram of landscape similarity values at sampling locations
hist(su.samp$locations$land_sim, 4, main = "Landscape Similarity")
Clean files from temporary directory
unlink(c(paste(o, "/wasoil.zip", sep = ""), d), recursive = TRUE)