iter_sample_poly: Sample covariates under a polygon

View source: R/dsmartr_iterate.R

iter_sample_polyR Documentation

Sample covariates under a polygon

Description

Randomly selects n cells for sampling and assigns them a soil class based on the overlying map polygon's components.

Usage

iter_sample_poly(
  pd = NULL,
  cs = NULL,
  ps = NULL,
  nscol = NULL,
  cellcol = NULL,
  t_factor = NULL
)

Arguments

pd

A single-row sf object containing soil attributes and geometry. Usually output of running split(x, seq(nrow(x))) on a polygon sf dataframe.

cs

String; stub of attribute column names holding soil class data

ps

String; stub of attribute column names folding soil percentage data

nscol

String; name of attribute holding number of samples needed

cellcol

String; name of attriute holding list of raster cells to sample from

t_factor

Integer; dirichlet dampener, supplied by parent function

Value

A data frame containing two columns: weighted random allocation of soil classes, and cell numbers.

Examples

## Not run: 
# run prep_polygons() and prep_points() examples, then:
sample_points <- iter_sample_poly(pd = pr_ap[1, ], cs = 'CLASS', ps = 'PERC',
nscol = 'n_samples', cellcol = 'intersecting_cells', t_factor = t_factor)
## End(Not run)

obrl-soil/dsmartr documentation built on Feb. 1, 2024, 10:57 p.m.