sample_existing {sgsR} | R Documentation |
Sample existing
Description
Sub-sample an existing sample. Four sampling methods are available:
clhs
, balanced
, srs
and strat
.
Usage
sample_existing(
existing,
nSamp,
raster = NULL,
type = "clhs",
access = NULL,
buff_inner = NULL,
buff_outer = NULL,
details = FALSE,
filename = NULL,
overwrite = FALSE,
...
)
Arguments
existing |
sf 'POINT'. Existing plot network. |
nSamp |
Numeric. Number of desired samples. |
raster |
SpatRaster. Raster to guide the location of the samples. If |
type |
Character. A string indicating the type of sampling method to use.
Possible values are |
access |
sf. Road access network - must be lines. |
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. |
details |
Logical. If |
filename |
Character. Path to write output samples. |
overwrite |
Logical. Choice to overwrite existing |
... |
Additional arguments for the sampling method selected. |
Value
An sf object of samples or a list object if details = TRUE
Note
When type = "clhs"
or type = "balanced"
all attributes in existing
will be used for sampling.
Remove attributes not indented for sampling' prior to using this algorithm.
Author(s)
Tristan R.H. Goodbody
See Also
Other sample functions:
sample_ahels()
,
sample_balanced()
,
sample_clhs()
,
sample_nc()
,
sample_srs()
,
sample_strat()
,
sample_sys_strat()
,
sample_systematic()
Examples
r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)
#--- generate an existing sample adn extract metrics ---#
e <- sample_systematic(raster = mr, cellsize = 200)
e <- extract_metrics(existing = e, mraster = mr)
#--- perform clhs (default) sub-sampling ---#
sample_existing(
existing = e,
nSamp = 50
)
#--- perform balanced sub-sampling ---#
sample_existing(
existing = e,
nSamp = 50,
type = "balanced"
)
#--- perform simple random sub-sampling ---#
sample_existing(
existing = e,
nSamp = 50,
type = "srs"
)