BackgroundPoints: Generate background points for species distribution modelling

View source: R/BackgroundPoints.R

BackgroundPointsR Documentation

Generate background points for species distribution modelling

Description

This function generates a set of species-specific background points using a variety of methods. These points can be generally across a given training area, or if environmental data are provided, environmental subsampling (sensu Varela et al. 2014) can be conducted. If a list of buffers around the occurrence points of each species are provided, BackgroundPoints can conduct spatially-constrained sampling within the buffer (spatial_weights = 1) or a hybrid method (spatial_weights between 0 and 1).

Usage

BackgroundPoints(
  spplist,
  envdata,
  output,
  nbg = 5000,
  spatial_weights = 0,
  buffers,
  method = "Varela",
  PCA = "Y",
  ncores = 1
)

Arguments

spplist

a vector of species names (used for the generation of output file names).

envdata

a SpatRaster or list of raster files corresponding to the area the model will be trained on. If environmental subsampling is desired (method = "Varela"), all environmental layers used for the modelling should be included.

output

a file folder where the output background point files will be placed.

nbg

either a single integer or a vector of the same length as spplist, corresponding to the number of background points generated for each set of background points. Should be in the same order as the species list.

spatial_weights

a number between 0 and 1 determining the percentage of background points sampled within the given buffer. A 1 indicates that background points are exclusively sampled from within the buffers, whereas a 0 indicates random sampling throughout the training area.

buffers

(optional) a list of shapefiles (SpatVec) or a list of file paths for the buffers. Required if spatial_weights is not 0. Should be in the same order as the species list. If only one species is needed, can be a single SpatialPolygon* object.

method

either "Varela" or "random", where "Varela" incorporates environmental subsampling (see Varela et al. 2014) and "random" simply randomly samples background points. Note that if method = "Varela", exact numbers of background points cannot be guaranteed.

PCA

(optional). The number of PC axes to use when binning climate data for environmental subsampling. Can be a number from 1 to the number of environmental variables. Default selects the number of axes that account for 95% of the environmental variation. If set to NA, PCA will not be run (for use when there are categorical variables, for instance).

ncores

the number of computer cores to parallelize the background point generation on. Default is 1. Using one fewer core than the computer has is usually optimal.

Value

writes .csv files of background points for each species in spplist to a directory provided by the output argument. These files have the coordinates of the points and the environmental values at each point. In addition, if method = "Varela", a .csv file is written out with the number of background points generated for each species, as the exact number of points may vary.


brshipley/megaSDM documentation built on Nov. 26, 2024, 6:08 a.m.