PredictEnv: Project, clip, and store forecasted/hindcasted environmental...

View source: R/PredictEnv.R

PredictEnvR Documentation

Project, clip, and store forecasted/hindcasted environmental rasters for SDM prediction

Description

This function takes lists of SpatRasters that correspond to future or past time periods of a single climate model (e.g., RCP4.5, CCSM3), ensures that the environmental variables are the same as those that the model will be developed on, and projects, clips, and resamples these layers to the characteristics of a given study region. If more than one climate scenario is required, run this function multiple times for each climate scenario.

Usage

PredictEnv(
  studylayers,
  futurelayers,
  time_periods,
  output = NA,
  scenario_name = NA,
  maxentproj = TRUE
)

Arguments

studylayers

A single SpatRaster or list of raster files that constitute all environmental variables and parameters (e.g., extent, resolution) used for projecting the modelled relationship (see $study in megaSDM::TrainStudyEnv).

futurelayers

A list of SpatRasters or vectors of file-names corresponding to the environmental variables at the different time periods the model will be forecasted/hindcasted to.

time_periods

a vector of the time periods the models will be projected to, with the first element as the year the model will be trained on (usually the current data). The projected time periods should be given in the same order as the list given in futurelayers. If no precise years are available (e.g., using data from the Last Glacial Maximum), order the futurelayers from current to least current (farthest into the future/past) and give character strings for the years (e.g., "LGM"). If running dispersal analyses, time_periods must be numeric (e.g., -21000 instead of "LGM").

output

If the rasters are to be written to the computer, the full path of the directory where they will be written out to as .grd files. If there are multiple climate scenarios wanted in this SDM analysis, give the output directory the name of the climate scenario (e.g., ".../output/RCP4.5). If set to NA (the default), the rasters will not be written out and will be returned as the value of this function.

scenario_name

(optional) If the rasters are to be written to the disk, a character string with the name of the climate model/scenario. A sub-directory will be created within output and files will be placed in there. If only one distinct climate scenario is needed, still give it a name for reference in other functions within megaSDM.

maxentproj

TRUE/FALSE: Will the MaxEntProj step be run on these data? If so, the NA value of the raster will be set to the maximum raster value + 0.01 instead of the non-numeric NaN when written out.

Value

Returns a list of multi-layer SpatRasters, with each SpatRaster corresponding to a time period.


brshipley/megaSDM documentation built on Nov. 26, 2024, 6:08 a.m.