Skip to contents

The function is a wrapper around thin from spThin package. It makes spatial thinning easy for multi-class input data set. This function is handy and flexible: can support xy coordinates, spatialPoints, or simple features. It assumes that data are in projected planar coordinates system; preferably Universal Transverse Mercator (UTM). There is no restrictions on number of columns in the data set as long as data is in the required format.

Usage

spatial_thinning_class(
  data,
  spatial = FALSE,
  coords = c("X", "Y"),
  distance,
  class = "class"
)

Arguments

data

The input data. It can be either an 'sf' object, 'SpatialPoints' object, or a data frame.

spatial

Logical value indicating whether the input data is spatial data (either 'sf' or 'SpatialPoints'). Default is FALSE.

coords

The names of the coordinate variables to use for spatial operations. By default, it is set to c("X", "Y").

distance

The distance threshold for thinning. Points within this distance will be reduced to a single point.

class

multi-class variable or strata variable. For each class thinning will be applied based on specified distance.

Value

A data frame containing the spatially thinned classes.

Details

Spatial thinning expect the data in the projected coordinate system, the distance value is the threshold which limits the number of observations. All the observations, in a particular class, smaller than the distance thresholds are deleted. If there are more than two classes, minimum distance between observations from each class.

References

Aiello-Lammens, M. E., Boria, R. A., Radosavljevic, A. , Vilela, B. and Anderson, R. P. (2015). spThin: an Rpackage for spatial thinning of species occurrence records for use in ecological niche models. Ecography, 38:541-545. URL https://onlinelibrary.wiley.com/doi/10.1111/ecog.01132.

Examples

## load data from the package
tdat <- landcover

# Run spatial thinning (sf format)
stc <- spatial_thinning_class(data = tdat,spatial = TRUE,
coords = NULL,distance = 10000,class = "Class_name")
#> [1] "Running spatial random thinning of class: 1"
#> [1] "Running spatial random thinning of class: 2"
#> [1] "Running spatial random thinning of class: 3"
#> [1] "Running spatial random thinning of class: 4"
#> [1] "Running spatial random thinning of class: 5"
#> [1] "Running spatial random thinning of class: 6"
#> [1] "Running spatial random thinning of class: 7"


if (FALSE) {
data <- landcover
spatial_thinning_class(data = landcover, spatial = TRUE, coords = NULL,
distance = 10000, class = "Class_name")
}