Sampling based on a stratified raster.
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
)
An sf object with nSamp
stratified samples.
spatRaster. Stratification raster to be used for sampling.
Numeric. Number of desired samples. existing
, include
and force
influence this value.
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 by nSamp
)
for each strata, or "manual"
for user defined strata weights defined using weights
.
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 for mindist
. existing, include, remove
are ignored when method = "random"
.
Numeric. Only applicable when allocation = "manual"
. Vector of weights where sum(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.
Logical. Default = FALSE
- force nSamp
to be exactly the user defined value
in cases where nSamp
and sraster
strata count are not equally divisible. Additional samples often need to be allocated or removed
based on rounding differences resulting from proportional differences between nSamp
and strata coverages in sraster
.
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 when existing
is provided.
spatRaster. ALS metric raster. Required when allocation = optim
.
Numeric. Minimum allowable distance between selected
samples. Default = NULL
.
sf 'POINT' or data.frame. Existing plot network.
Logical. If TRUE
include existing
plots in nSamp
total.
Logical. If TRUE
randomly remove samples from over represented strata to meet allocated sample numbers.
Used only when existing
and include
are both TRUE
.
sf 'LINESTRING' or 'MULTILINESTRING'. Access network.
Numeric. Inner buffer boundary specifying distance from access where plots cannot be sampled.
Numeric. Outer buffer boundary specifying distance from access where plots can be sampled.
Numeric. Number of row in the focal window (default = 3
).
Numeric. Number of columns in the focal window (default = 3
).
Logical. Plots samples of type `existing` (if provided; croses) and `new` (circles) along with sraster
.
Logical. If FALSE
(default) output is sf object of
stratified samples. If TRUE
return a list
where $details
additional sampling information and $raster
is an sf object of stratified samples.
Character. Path to write output samples.
Logical. Choice to overwrite existing filename
if it exists.
Tristan R.H. Goodbody & Martin Queinnec
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
Other sample functions:
sample_ahels()
,
sample_balanced()
,
sample_clhs()
,
sample_existing()
,
sample_nc()
,
sample_srs()
,
sample_sys_strat()
,
sample_systematic()
#--- 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
)
Run the code above in your browser using DataLab