niche | R Documentation |
This function maps the species data (either presence/absence or probability of occurrence/habitat suitability) into a two-dimensional environmental space (i.e., based on two environmental variables) to characterise ecological niche based on the specified environmental variables.
niche(x,h,n,.size,plot,out,...)
x |
A |
h |
A |
n |
A character vector specifying the names of environmental variables (two names) that should be used to map the ecological niche; if |
.size |
optional; a numeric value (default: 1e6) specifies the size of the maximum number of records should be used to generate the ecological niche map; would be useful when the |
plot |
logical, specifies whether the generated niche should be plotted |
out |
logical, specifies whether the niche should be returned by the function; it will be |
... |
additional arguments includingthe argument |
As an additional argument, a user may specify gg
which is logical, specifies whether the plot should be generated using the ggplot2 package (if the package is installed), otherwise, the raster package is used to generate the plot.
- ...
: additional arguments for the plot
function (e.g., xlab, ylab, main, col, ...) can be used with the function
an object of class .nicheRaster
that contains some information about the environmental variable, and a RasterLayer (100x100) that represents the two-dimensional ecological niche.
Babak Naimi naimi.b@gmail.com
https://www.biogeoinformatics.org/
Naimi, B., Araujo, M.B. (2016) sdm: a reproducible and extensible R platform for species distribution modelling, Ecography, 39:368-375, DOI: 10.1111/ecog.01881
## Not run:
file <- system.file("external/species.shp", package="sdm") # get the location of the species data
species <- vect(file) # read the shapefile
path <- system.file("external", package="sdm") # path to the folder contains the data
lst <- list.files(path=path,pattern='asc$',full.names = T) # list the name of the raster files
# stack is a function in the raster package, to read/create a multi-layers raster dataset
preds <- rast(lst) # making a raster object
names(preds) # 4 environmental variables are used!
d <- sdmData(formula=Occurrence~., train=species, predictors=preds)
d
# fit models:
m <- sdm(Occurrence~.,data=d,methods=c('rf','glm','brt'))
# ensemble using weighted averaging based on AUC statistic:
p1 <- ensemble(m, newdata=preds,setting=list(method='weighted',stat='AUC'))
plot(p1, main='Habitat Suitability in Geographic Space')
# Mapping Ecological Niche using selected two variables
niche(x=preds, h=p1, c('precipitation','temperature'))
niche(x=preds, h=p1, c('vegetation','temperature'))
# in case if you do not have the habitat suitability map but species data:
niche(x=preds, h=species, c('vegetation','temperature','Occurrence'))
niche(x=preds, h=d, n=c('vegetation','temperature','Occurrence'), rnd=2)
# rnd is the argument specifies the decimal degrees to which the values on axis rounded.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.