reduceSpatialCorrelation: Applies "thinning" to a set of coordinates to reduce their...

Description Usage Arguments Value Author(s) Examples

View source: R/reduceSpatialCorrelation.R

Description

This function reduces the spatial clustering of a set of presence records. It is intended to reduce spatial autocorrelation, and reduce sampling bias, particularly at larger geographical scales. It takes as input a set of coordinates, a brick or stack of environmental variables, and a minimum distance, and returns a new set of coordinates in which the distance between adjacent points is equal or higher than the established minimum distance. This operation is named "thinning", and helps to reduce the spatial correlation of a presence dataset. This function applies thinning, but preserves the presence records representing the extremes of any of the predictive variables provided.

Usage

1
2
3
4
5
6
7
8
reduceSpatialCorrelation(
xy,
variables,
minimum.distance = NULL,
random.start = FALSE,
seed = NULL,
verbose = FALSE
)

Arguments

xy

A data frame with two columns with coordinates x and y. Column names are irrelevant as long as the first column represents the x coordinate, and the second column represents the y coordinate.

variables

A raster brick or stack with environmental variables. Must be in the same reference system of xy.

minimum.distance

Numeric, minimum distance between consecutive points in the output dataset. Defaults to the resolution of variables. The minimum distance can be extracted from the resolution of variables, as in minimum.distance <- xres(variables).

random.start

Boolean, defaults to FALSE. If TRUE, the xy dataset is randomly reshuffled so the start of the thinning changes, and with that, the output dataset.

seed

Integer determining a random seed. Only relevant when random.start = TRUE. Added to allow reproducibility in the generation of datasets with a random start.

verbose

Boolean. If FALSE (default), all messages are supressed.

Value

A data frame with the same columns as xy, but a lower number of records.

Author(s)

Blas Benito <blasbenito@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
data("virtualSpecies")
data(europe2000)
xy.thinned <- reduceSpatialCorrelation(
  xy = virtualSpecies$observed.presence,
  variables = europe2000,
  minimum.distance = 4
)
xy.thinned

#generating datasets with different starting points
#generates a different dataset with different nrow on each run
xy.thinned <- reduceSpatialCorrelation(
  xy = virtualSpecies$observed.presence,
  variables = europe2000,
  minimum.distance = 4,
)
nrow(virtualSpecies$observed.presence)
nrow(xy.thinned)

BlasBenito/SDMworkshop documentation built on March 4, 2020, 4:16 a.m.