sample_srs {sgsR} | R Documentation |
Simple random sampling
Description
Randomly sample within a stratification raster extent.
Usage
sample_srs(
raster,
nSamp,
mindist = NULL,
access = NULL,
buff_inner = NULL,
buff_outer = NULL,
plot = FALSE,
filename = NULL,
overwrite = FALSE
)
Arguments
raster |
spatRaster. Raster to be used for random sampling. |
nSamp |
Numeric. Number of desired samples. |
mindist |
Numeric. Minimum allowable distance between selected
samples. |
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. |
plot |
Logical. Plots output strata raster with samples. |
filename |
Character. Path to write output samples. |
overwrite |
Logical. Choice to overwrite existing |
Value
An sf object with nSamp
randomly sampled points.
Author(s)
Tristan R.H. Goodbody & Martin Queinnec
See Also
Other sample functions:
sample_ahels()
,
sample_balanced()
,
sample_clhs()
,
sample_existing()
,
sample_nc()
,
sample_strat()
,
sample_sys_strat()
,
sample_systematic()
Examples
#--- Load raster and access files ---#
r <- system.file("extdata", "sraster.tif", package = "sgsR")
sr <- terra::rast(r)
a <- system.file("extdata", "access.shp", package = "sgsR")
ac <- sf::st_read(a)
#--- perform simple random sampling ---#
sample_srs(
raster = sr,
nSamp = 200,
)