This function is used internally by function setup_sdmdata to define the area where pseudoabsences will be sampled in different ways. First, it can create an inclusion buffer, within which the pseudoabsences will be sampled, to restrict model evaluation to accesible areas. This can be performed by either setting a user-defined shapefile, or by drawing a buffer around the species occurrences: a geographic distance fixed value, or the mean, median or maximum pairwise distance between occurrences. In addition to this, an euclidean environmental distance filter can be superimposed to the previous step, to control for overfitting by excluding areas that are too close to the occurrence points, either in the environmental space or in the geographic space. The function will return the resulting buffer as a RasterStack object with the same resolution and NA values of the predictors RasterStack.

create_buffer(species_name, occurrences, lon = "lon", lat = "lat",
  predictors, buffer_type = "none", buffer_shape, dist_buf = NULL,
  env_filter = FALSE, env_distance = "centroid", min_env_dist = NULL,
  min_geog_dist = NULL, models_dir = "./models", write_buffer = FALSE)

Arguments

species_name

A character string with the species name. Because species name will be used as a directory name, avoid non-ASCII characters, spaces and punctuation marks. Recommendation is to adopt "Genus_species" format. See names in example_occs as an example

occurrences

A data frame with occurrence data. Data must have at least columns with latitude and longitude values of species occurrences. See example_occs as an example

lon

The name of the longitude column. Defaults to "lon"

lat

The name of the latitude column. Defaults to "lat"

predictors

A Raster or RasterStack object with the environmental raster layers

buffer_type

Character string indicating whether the buffer should be calculated using the "mean", "median", "maximum" distance between occurrence points, or an absolute geographic "distance". If set to "user", a user-supplied shapefile will be used as a sampling area, and buffer_shape needs to be specified. If NULL, no distance buffer is applied. If set to "distance", dist_buf needs to be specified

buffer_shape

User-defined buffer shapefile in which pseudoabsences will be generated. Needs to be specified if buffer_type = "user"

dist_buf

Defines the width of the buffer. Needs to be specified if buffer_type = "distance". Distance unit is in the same unit of the RasterStack of predictor variables

env_filter

Logical. Should an euclidean environmental filter be applied? If TRUE, env_distance and min_env_dist need to be specified. Areas closest than min_env_dist (expressed in quantiles in the environmental space)will be omitted from the pseudoabsence sampling

env_distance

Character. Type of environmental distance, either "centroid" or "mindist". Defaults to "centroid", the distance of each raster pixel to the environmental centroid of the distribution. When set to "mindist", the minimum distance of each raster pixel to any of the occurrence points is calculated. Needs to be specified if env_filter = TRUE. A minimum value needs to be specified (parameter min_env_dist)

min_env_dist

Numeric. Sets a minimum value to exclude the areas closest (in the environmental space) to the occurrences or their centroid, expressed in quantiles, from 0 (the closest) to 1. Defaults to 0.05, excluding areas belonging to the 5 since this is based on quantiles, and environmental similarity can take large negative values, this is an abitrary value

min_geog_dist

Optional, numeric. A distance for the exclusion of the areas closest to the occurrence points (in the geographical space). Distance unit is in the same unit of the RasterStack of predictor variables

models_dir

Folder path to save the output files. Defaults to "./models"

write_buffer

Logical. Should the resulting buffer RasterLayer be written? Defaults to FALSE

Value

Table of pseudoabsence points sampled within the selected distance

A RasterLayer object containing the final buffer around the occurrence points

References

VanDerWal, J., Shoo, L. P., Graham, C., & Williams, S. E. (2009). Selecting pseudo-absence data for presence-only distribution modeling: How far should you stray from what you know? Ecological Modelling, 220(4), 589-594. doi:10.1016/j.ecolmodel.2008.11.010

See also

buffer in raster package

randomPoints in dismo package

Examples

library(raster)
#> Loading required package: sp
sp <- names(example_occs)[1]
occs <- example_occs[[1]]
buf <- create_buffer(species_name = sp,
                     occurrences = occs,
                     predictors = example_vars)
#> No inclusion buffer was applied
plot(buf)