sample_background {tidysdm}R Documentation

Sample background points for SDM analysis

Description

This function samples background points from a raster given a set of presences. The locations returned as the center points of the sampled cells, which can overlap with the presences (in contrast to pseudo-absences, see sample_pseudoabs). The following methods are implemented:

Usage

sample_background(
  data,
  raster,
  n,
  coords = NULL,
  method = "random",
  class_label = "background",
  return_pres = TRUE
)

Arguments

data

An sf::sf data frame, or a data frame with coordinate variables. These can be defined in coords, unless they have standard names (see details below).

raster

the terra::SpatRaster from which cells will be sampled (the first layer will be used to determine which cells are NAs, and thus can not be sampled). If sampling is "biased", then the sampling probability will be proportional to the values on the first layer (i.e. band) of the raster.

n

number of background points to sample.

coords

a vector of length two giving the names of the "x" and "y" coordinates, as found in data. If left to NULL, the function will try to guess the columns based on standard names c("x", "y"), c("X","Y"), c("longitude", "latitude"), or c("lon", "lat").

method

sampling method. One of 'random', 'dist_max', and 'targeted'. For dist_max, the maximum distance is set as an additional element of a vector, e.g c('dist_max',70000).

class_label

the label given to the sampled points. Defaults to background

return_pres

return presences together with background in a single tibble.

Details

Note that the units of distance depend on the projection of the raster.

Value

An object of class tibble::tibble. If presences are returned, the presence level is set as the reference (to match the expectations in the yardstick package that considers the first level to be the event).


[Package tidysdm version 0.9.5 Index]