Learn R Programming

sgsR (version 1.5.0)

sample_srs: 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
)

Value

An sf object with nSamp randomly sampled points.

Arguments

raster

spatRaster. Raster to be used for random sampling.

nSamp

Numeric. Number of desired samples.

mindist

Numeric. Minimum allowable distance between selected samples. Default = NULL.

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 filename if it exists.

Author

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

Run this code
#--- 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,
)

Run the code above in your browser using DataLab