pkgdown/mathjax-config.html

Skip to contents

Reduce spatial autocorrelation by subsampling sites using various methods.

Usage

subsample(
  coords,
  n = NULL,
  method = c("grid", "random", "thinning"),
  cell_size = NULL,
  min_dist = NULL,
  seed = NULL
)

Arguments

coords

A data.frame with columns x and y containing site coordinates.

n

Integer. Target number of sites to retain. If NULL, determined by cell_size or min_dist.

method

Character. Subsampling method: "grid" (default), "random", or "thinning".

cell_size

Numeric. Grid cell size for method = "grid". One site retained per cell.

min_dist

Numeric. Minimum distance between retained sites for method = "thinning".

seed

Integer. Random seed for reproducibility.

Value

Integer vector of row indices to retain.

Details

Methods:

  • "grid": Overlay a grid and retain one random site per cell.

  • "random": Simple random subsample of n sites.

  • "thinning": Iteratively remove sites until minimum distance is achieved.

References

Aiello-Lammens, M.E., Boria, R.A., Radosavljevic, A., et al. (2015). spThin: an R package for spatial thinning of species occurrence records for use in ecological niche models. Ecography, 38, 541-545.

Lennon, J.J., Koleff, P., Greenwood, J.J.D. & Gaston, K.J. (2004). Contribution of rarity and commonness to patterns of species richness. Ecology Letters, 7, 81-87.

Examples

# \donttest{
coords <- data.frame(x = runif(50) * 100, y = runif(50) * 100)
species <- matrix(rbinom(50 * 30, 1, 0.3), nrow = 50)

keep <- subsample(coords, method = "grid", cell_size = 20)
sac <- spacc(species[keep, ], coords[keep, ])
# }