niche: Generate and plot Ecological Niche

Description Usage Arguments Details Value Author(s) References Examples

Description

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.

Usage

1
niche(x,h,n,.size,plot,out,...)

Arguments

x

A Raster* object (or sdmdata) containing environmental variables

h

A RasterLayer, or SpatialPoints, or sdmdata object that represents species data either in the form of habitat suitability (e.g., probability of occurrence) or presence-absence (or even presence-only) data

n

A character vector specifying the names of environmental variables (two names) that should be used to map the ecological niche; if h is a SpatialPoints or sdmdata object, a third name may be added specifying the species name (e.g., the name of the column in SpatialPointsDataFrame contains species data)

.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 Raster* object introduced in x is big, then a random sample with the specified .size will be drawn based on which the niche is generated

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 TRUE if plot is FALSE

...

additional arguments includingthe argument gg (see details) and other arguments that passed to the plot function

Details

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

Value

an object of class .nicheRaster that contains some information about the environmental variable, and a RasterLayer (100x100) that represents the two-dimensional ecological niche.

Author(s)

Babak Naimi naimi.b@gmail.com

https://www.r-gis.net/

https://www.biogeoinformatics.org

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Not run: 

file <- system.file("external/species.shp", package="sdm") # get the location of the species data

species <- shapefile(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 <- stack(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,filename='ens1.grd',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)

sdm documentation built on Nov. 12, 2021, 9:06 a.m.

Related to niche in sdm...