ensemble.zones {BiodiversityR} | R Documentation |
Mapping of environmental zones based on the Mahalanobis distance from centroids in environmental space.
Description
Function ensemble.zones
maps the zone of each raster cell within a presence map based on the minimum Mahalanobis distance (via mahalanobis
) to different centroids. Function ensemble.centroids
defines centroids within a presence map based on Principal Components Analysis (via rda
) and K-means clustering (via kmeans
).
Usage
ensemble.zones(presence.raster = NULL, centroid.object = NULL,
x = NULL, ext = NULL,
RASTER.species.name = centroid.object$name, RASTER.stack.name = x@title,
RASTER.format = "GTiff", RASTER.datatype = "INT2S", RASTER.NAflag = -32767,
CATCH.OFF = FALSE)
ensemble.centroids(presence.raster = NULL, x = NULL, categories.raster = NULL,
an = 10000, ext = NULL, name = "Species001",
pca.var = 0.95, centers = 0, use.silhouette = TRUE,
plotit = FALSE, dev.new.width = 7, dev.new.height = 7)
Arguments
presence.raster |
RasterLayer object ( |
centroid.object |
Object listing values for centroids and covariance to be used with the |
x |
RasterStack object ( |
ext |
an Extent object to limit the predictions and selection of background points to a sub-region of |
RASTER.species.name |
First part of the names of the raster file that will be generated, expected to identify the modelled species (or organism) |
RASTER.stack.name |
Last part of the names of the raster file that will be generated, expected to identify the predictor stack used |
RASTER.format |
Format of the raster files that will be generated. See |
RASTER.datatype |
Format of the raster files that will be generated. See |
RASTER.NAflag |
Value that is used to store missing data. See |
CATCH.OFF |
Disable calls to function |
categories.raster |
RasterLayer object ( |
an |
Number of presence points to be used for Principal Components Analysis (via |
name |
Name for the centroid object, for example identifying the species and area for which centroids are calculated |
pca.var |
Minimum number of axes based on the fraction of variance explained (default value of 0.95 indicates that at least 95 percent of variance will be explained on the selected number of axes). Axes and coordinates are obtained from Principal Components Analysis ( |
centers |
Number of centers (clusters) to be used for K-means clustering ( |
use.silhouette |
If |
plotit |
If |
dev.new.width |
Width for new graphics device ( |
dev.new.height |
Heigth for new graphics device ( |
Details
Function ensemble.zones
maps the zone of each raster cell of a predefined presence map, whereby the zone is defined as the centroid with the smallest Mahalanobis distance. The function returns a RasterLayer object (raster
) and possibly a KML layer.
Function ensemble.centroid
provides the centroid locations in environmental space and a covariance matrix (cov
) to be used with mahalanobis
. Also provided is information on the analogue presence location that is closest to the centroid in environmental space.
Value
Function ensemble.centroid
returns a list with following objects:
centroids |
Location of centroids in environmental space |
centroid.analogs |
Location of best analogs to centroids in environmental space |
cov.mahal |
Covariance matrix |
Author(s)
Roeland Kindt (World Agroforestry Centre)
See Also
Examples
## Not run:
# get predictor variables
library(dismo)
predictor.files <- list.files(path=paste(system.file(package="dismo"), '/ex', sep=''),
pattern='grd', full.names=TRUE)
predictors <- stack(predictor.files)
predictors <- subset(predictors, subset=c("bio1", "bio5", "bio6", "bio7", "bio8",
"bio12", "bio16", "bio17"))
predictors
predictors@title <- "base"
# choose background points
background <- randomPoints(predictors, n=1000, extf=1.00)
# predicted presence from GLM
ensemble.calibrate.step1 <- ensemble.calibrate.models(
x=predictors, p=pres, a=background,
species.name="Bradypus",
MAXENT=0, MAXLIKE=0, MAXNET=0, CF=0,
GBM=0, GBMSTEP=0, RF=0, GLM=1, GLMSTEP=0,
GAM=0, GAMSTEP=0, MGCV=0, MGCVFIX=0,
EARTH=0, RPART=0, NNET=0, FDA=0, SVM=0, SVME=0, GLMNET=0,
BIOCLIM.O=0, BIOCLIM=0, DOMAIN=0, MAHAL=0, MAHAL01=0,
Yweights="BIOMOD",
models.keep=TRUE)
ensemble.raster.results <- ensemble.raster(xn=predictors,
models.list=ensemble.calibrate.step1$models,
RASTER.species.name="Bradypus", RASTER.stack.name="base")
# get presence map as for example created with ensemble.raster in subfolder 'ensemble/presence'
# presence values are values equal to 1
presence.file <- paste("ensembles//presence//Bradypus_base.tif", sep="")
presence.raster <- raster(presence.file)
# let cascadeKM decide on the number of clusters
dev.new()
centroids <- ensemble.centroids(presence.raster=presence.raster,
x=predictors, an=1000, plotit=T)
ensemble.zones(presence.raster=presence.raster, centroid.object=centroids,
x=predictors, RASTER.species.name="Bradypus")
dev.new()
zones.file <- paste("ensembles//zones//Bradypus_base.tif", sep="")
zones.raster <- raster(zones.file)
max.zones <- maxValue(zones.raster)
plot(zones.raster, breaks=c(0, c(1:max.zones)),
col = grDevices::rainbow(n=max.zones), main="zones")
ensemble.zones(presence.raster=presence.raster, centroid.object=centroids,
x=predictors, RASTER.species.name="Bradypus")
# manually choose 6 zones
dev.new()
centroids6 <- ensemble.centroids(presence.raster=presence.raster,
x=predictors, an=1000, plotit=T, centers=6)
ensemble.zones(presence.raster=presence.raster, centroid.object=centroids6,
x=predictors, RASTER.species.name="Bradypus6")
dev.new()
zones.file <- paste("ensembles//zones//Bradypus6_base.tif", sep="")
zones.raster <- raster(zones.file)
max.zones <- maxValue(zones.raster)
plot(zones.raster, breaks=c(0, c(1:max.zones)),
col = grDevices::rainbow(n=max.zones), main="six zones")
## End(Not run)