Sampling based on a stratified raster.
Usage
sample_strat(
sraster,
nSamp,
allocation = "prop",
method = "Queinnec",
weights = NULL,
force = FALSE,
mraster = NULL,
mindist = NULL,
existing = NULL,
include = FALSE,
remove = FALSE,
access = NULL,
buff_inner = NULL,
buff_outer = NULL,
wrow = 3,
wcol = 3,
plot = FALSE,
details = FALSE,
filename = NULL,
overwrite = FALSE
)
Arguments
- sraster
spatRaster. Stratification raster to be used for sampling.
- nSamp
Numeric. Number of desired samples.
existing
,include
andforce
influence this value.- allocation
Character. Allocation algorithm to be used. Either
prop
(default) for proportional allocation,optim
for optimal allocation (equal sampling cost),equal
for equal number of samples (defined bynSamp
) for each strata, or"manual"
for user defined strata weights defined usingweights
.- method
Character. Sampling design approach
"Queinnec"
(default) or"random"
."Queinnec"
method is described in notes below."random"
performs traditional stratified random sampling where probability to sample each cell within each stratum is equal assuming default parameters formindist
.existing, include, remove
are ignored whenmethod = "random"
.- weights
Numeric. Only applicable when
allocation = "manual"
. Vector of weights wheresum(weights) == 1
. Vector length must be equal to the number of unique strata where the first numeric value corresponds to stratum 1, second stratum 2 etc.- force
Logical.
Default = FALSE
- forcenSamp
to be exactly the user defined value in cases wherenSamp
andsraster
strata count are not equally divisible. Additional samples often need to be allocated or removed based on rounding differences resulting from proportional differences betweennSamp
and strata coverages insraster
. In these instances samples are either added to strata with the lowest number of samples or are removed from strata with the highest number of samples. Has no effect whenexisting
is provided.- mraster
spatRaster. ALS metric raster. Required when
allocation = optim
.- mindist
Numeric. Minimum allowable distance between selected samples.
Default = NULL
.- existing
sf 'POINT' or data.frame. Existing plot network.
- include
Logical. If
TRUE
includeexisting
plots innSamp
total.- remove
Logical. If
TRUE
randomly remove samples from over represented strata to meet allocated sample numbers. Used only whenexisting
andinclude
are bothTRUE
.- access
sf 'LINESTRING' or 'MULTILINESTRING'. Access network.
- buff_inner
Numeric. Inner buffer boundary specifying distance from access where plots cannot be sampled.
- buff_outer
Numeric. Outer buffer boundary specifying distance from access where plots can be sampled.
- wrow
Numeric. Number of row in the focal window (
default = 3
).- wcol
Numeric. Number of columns in the focal window (
default = 3
).- plot
Logical. Plots samples of type `existing` (if provided; croses) and `new` (circles) along with
sraster
.- details
Logical. If
FALSE
(default) output is sf object of stratified samples. IfTRUE
return a list where$details
additional sampling information and$raster
is an sf object of stratified samples.- filename
Character. Path to write output samples.
- overwrite
Logical. Choice to overwrite existing
filename
if it exists.
Note
The sampling is performed in 2 stages when method = "Queinnec"
:
Rule 1
- Sample within grouped stratum pixels defined within thewrow, wcol
parametersRule 2
- If no samples exist to satisfy Rule 1 individual stratum pixels are sampled.The rule applied to allocate each sample is defined in the
rule
attribute of output samples.
existing
may contain samples that fall in sraster
cells that are `NA`. If this occurs and include = TRUE
, `NA` samples
are separated during sampling and re-appended at the end of the sampling process.
If the sraster
provided contains factor values, the algorithm will automatically convert these into the numeric factor levels and
perform sampling using those values. The categories (factor values) will be extracted and appended to the algorithm output as the `category` attribute.
References
Queinnec, M., White, J. C., & Coops, N. C. (2021). Comparing airborne and spaceborne photon-counting LiDAR canopy structural estimates across different boreal forest types. Remote Sensing of Environment, 262 (August 2020), 112510. https://doi.org/10.1016/j.rse.2021.112510
See also
Other sample functions:
sample_ahels()
,
sample_balanced()
,
sample_clhs()
,
sample_existing()
,
sample_nc()
,
sample_srs()
,
sample_sys_strat()
,
sample_systematic()
Examples
#--- Load raster and access files ---#
r <- system.file("extdata", "sraster.tif", package = "sgsR")
sr <- terra::rast(r)
#--- perform stratified sampling random sampling ---#
sraster <- sample_strat(
sraster = sr,
nSamp = 50
)
#> Using 'Queinnec' sampling method.
#> Implementing proportional allocation of samples.
#> nSamp of 50 is not perfectly divisible based on strata distribution. nSamp of 51 will be returned. Use 'force = TRUE' to brute force to 50.
#> Processing strata : 1
#> Processing strata : 2
#> Processing strata : 3
#> Processing strata : 4