View source: R/create_buffer.R
create_buffer | R Documentation |
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)
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
|
occurrences |
A data frame with occurrence data. Data must have at least
columns with latitude and longitude values of species occurrences.
See |
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 " |
buffer_shape |
User-defined buffer shapefile in which pseudoabsences
will be generated. Needs to be specified if |
dist_buf |
Defines the width of the buffer. Needs to be specified if
|
env_filter |
Logical. Should an euclidean environmental filter be
applied? If TRUE, |
env_distance |
Character. Type of environmental distance, either
" |
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
" |
write_buffer |
Logical. Should the resulting buffer RasterLayer be written? Defaults to FALSE |
Table of pseudoabsence points sampled within the selected distance
A RasterLayer object containing the final buffer around the occurrence points
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
buffer
in raster package
randomPoints
in dismo package
library(raster)
sp <- names(example_occs)[1]
occs <- example_occs[[1]]
buf <- create_buffer(species_name = sp,
occurrences = occs,
predictors = example_vars)
plot(buf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.