BIOMOD_Projection {biomod2} | R Documentation |
Project a range of calibrated species distribution models onto new environment
Description
This function allows to project a range of models built with the
BIOMOD_Modeling
function onto new environmental data (which can
represent new areas, resolution or time scales for example).
Usage
BIOMOD_Projection(
bm.mod,
proj.name,
new.env,
new.env.xy = NULL,
models.chosen = "all",
metric.binary = NULL,
metric.filter = NULL,
compress = TRUE,
build.clamping.mask = TRUE,
nb.cpu = 1,
seed.val = NULL,
...
)
Arguments
bm.mod |
a |
proj.name |
a |
new.env |
A |
new.env.xy |
(optional, default |
models.chosen |
a |
metric.binary |
(optional, default |
metric.filter |
(optional, default |
compress |
(optional, default |
build.clamping.mask |
(optional, default |
nb.cpu |
(optional, default |
seed.val |
(optional, default |
... |
(optional, see Details)) |
Details
If models.chosen = 'all'
, projections are done for all calibration and pseudo absences
runs if applicable.
These projections may be used later by the
BIOMOD_EnsembleForecasting
function.
If build.clamping.mask = TRUE
, a raster file will be saved within the projection folder.
This mask values will correspond to the number of variables in each pixel that are out of their
calibration / validation range, identifying locations where predictions are uncertain.
...
can take the following values :
-
omit.na
: alogical
value defining whether all not fully referenced environmental points will getNA
as predictions or not -
on_0_1000
: alogical
value defining whether0 - 1
probabilities are to be converted to0 - 1000
scale to save memory on backup -
do.stack
: alogical
value defining whether all projections are to be saved as oneSpatRaster
object or severalSpatRaster
files (the default if projections are too heavy to be all loaded at once in memory) -
keep.in.memory
: alogical
value defining whether all projections are to be kept loaded at once in memory, or only links pointing to hard drive are to be returned -
output.format
: acharacter
value corresponding to the projections saving format on hard drive, must be either.grd
,.img
,.tif
or.RData
(the default ifnew.env
is given asmatrix
ordata.frame
)
Value
A BIOMOD.projection.out
object containing models projections, or links to saved
outputs.
Models projections are stored out of R (for memory storage reasons) in
proj.name
folder created in the current working directory :
the output is a
data.frame
ifnew.env
is amatrix
or adata.frame
it is a
SpatRaster
ifnew.env
is aSpatRaster
(or severalSpatRaster
objects, ifnew.env
is too large)raw projections, as well as binary and filtered projections (if asked), are saved in the
proj.name
folder
Author(s)
Wilfried Thuiller, Damien Georges
See Also
BIOMOD_Modeling
, BIOMOD_EnsembleModeling
,
BIOMOD_RangeSize
Other Main functions:
BIOMOD_EnsembleForecasting()
,
BIOMOD_EnsembleModeling()
,
BIOMOD_FormatingData()
,
BIOMOD_LoadModels()
,
BIOMOD_Modeling()
,
BIOMOD_RangeSize()
Examples
library(terra)
# Load species occurrences (6 species available)
data(DataSpecies)
head(DataSpecies)
# Select the name of the studied species
myRespName <- 'GuloGulo'
# Get corresponding presence/absence data
myResp <- as.numeric(DataSpecies[, myRespName])
# Get corresponding XY coordinates
myRespXY <- DataSpecies[, c('X_WGS84', 'Y_WGS84')]
# Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12)
data(bioclim_current)
myExpl <- terra::rast(bioclim_current)
# ---------------------------------------------------------------#
file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out")
if (file.exists(file.out)) {
myBiomodModelOut <- get(load(file.out))
} else {
# Format Data with true absences
myBiomodData <- BIOMOD_FormatingData(resp.var = myResp,
expl.var = myExpl,
resp.xy = myRespXY,
resp.name = myRespName)
# Model single models
myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData,
modeling.id = 'AllModels',
models = c('RF', 'GLM'),
CV.strategy = 'random',
CV.nb.rep = 2,
CV.perc = 0.8,
OPT.strategy = 'bigboss',
metric.eval = c('TSS','ROC'),
var.import = 3,
seed.val = 42)
}
# ---------------------------------------------------------------#
# Project single models
file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out")
if (file.exists(file.proj)) {
myBiomodProj <- get(load(file.proj))
} else {
myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut,
proj.name = 'Current',
new.env = myExpl,
models.chosen = 'all')
}
myBiomodProj
plot(myBiomodProj)