| distPres | R Documentation |
This function takes a matrix or data frame containing species presence (1) and absence (0) records and their spatial coordinates (optionally also a pre-computed pairwise distance matrix for all localities), and computes the (inverse) distance from each locality to the nearest presence locality for each species. It can be used to compute a simple spatial interpolation model of a species' distribution (e.g. Barbosa 2015, Areias-Guerreiro et al. 2016).
distPres(data, sp.cols, coord.cols = NULL, id.col = NULL,
dist.mat = NULL, CRS = NULL, method = "auto", suffix = "_D",
p = 1, inv = TRUE, verbosity = 2)
data |
a matrix or data frame containing, at least, two columns with spatial coordinates, and one column per species containing their presence (1) and absence (0) data, with localities in rows. |
sp.cols |
names or index numbers of the columns containing the species presences and absences in 'data'. It must contain only zeros (0) for absences and ones (1) for presences. |
coord.cols |
names or index numbers of the columns containing the spatial coordinates in 'data' (x and y, or longitude and latitude, in this order!). |
id.col |
optionally, the name or index number of a column (to be included in the output) containing locality identifiers in 'data'. |
dist.mat |
optional pre-computed pairwise distance matrix for the localities in 'data'. If provided, arguments 'CRS' and 'method' are not used. |
CRS |
(if 'dist.mat' is NULL) argument to pass to |
method |
(if 'dist.mat' is NULL) argument to pass to |
suffix |
character indicating the suffix to add to the distance columns in the resulting data frame. The default is |
p |
the power to which distance should be raised. The default is 1; use 2 or higher if you want more conservative distances. |
inv |
logical value indicating whether distance should be inverted (i.e., converted to proximity), in which case they will be standardized to vary between 0 and 1, and then subtracted from 1. The output will also vary between 0 and 1, with higher values meaning closer to a presence, and 1 meaning presence. The default is |
verbosity |
integer specifying the amount of messages to display along the process. The default is 2, for the maximum amount of messages available. |
This function returns a matrix or data frame containing the identifier column (if provided in 'id.col') and one column per species containing the distance (inverse by default, i.e. proximity) from each locality to the nearest presence of that species.
A. Marcia Barbosa
Areias-Guerreiro J., Mira A. & Barbosa A.M. (2016) How well can models predict changes in species distributions? A 13-year-old otter model revisited. Hystrix - Italian Journal of Mammalogy, in press. DOI: http://dx.doi.org/10.4404/hystrix-27.1-11867
Barbosa A.M. (2015) fuzzySim: applying fuzzy logic to binary similarity indices in ecology. Methods in Ecology and Evolution, 6: 853-858
dist
data(rotif.env)
head(rotif.env)
names(rotif.env)
## Not run:
# distance to presence (in meters):
rotifers.dist <- distPres(rotif.env, sp.cols = 18:47,
coord.cols = c("Longitude", "Latitude"), id.col = 1, p = 1,
inv = FALSE, suffix = "_D", CRS = "EPSG:4326")
head(rotifers.dist)
# inverse squared distance to presence (proximity):
rotifers.invd2 <- distPres(rotif.env, sp.cols = 18:47,
coord.cols = c("Longitude", "Latitude"), id.col = 1, p = 2,
inv = TRUE, suffix = "_iDsq", CRS = "EPSG:4326")
head(rotifers.invd2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.