Skip to contents

Download climatologies from the CHELSA v2.1.1 server, which can be used to run various types of models.

Usage

import_chelsa_v2(
  var.type = "bio",
  var.subtype = "bio",
  var.period,
  bioclim.type = NA,
  bioclim.number = NA,
  bioclim.period = NA,
  bioclim.ssp = NA,
  bioclim.model = NA,
  mypath = NA,
  create.dir = FALSE,
  save.output = FALSE
)

Arguments

var.type

The group of climatological variables to be accessed. One of "climatologies" (bioclimatic variables), "monthly", or "daily". Default is "climatologies".

var.subtype

The type of climatological variable to be downloaded from server. Use var.subtype = "bio" to download bioclimatic variables. See description for choices depending on whether var.type is "daily", "monthly" or "climatologies". If more than one is specified, it should be formatted as follows: c("subtype1", "subtype2").

var.period

The date or range of years for which to download the variable data. If a date range is supplied, it should be formatted as follows: c("date_range_start", "date_range_end"). See Description for choices depending on whether var.type is "daily", "monthly", or "climatologies".

bioclim.type

Used only if downloading bioclimatic variables (var.type = "climatologies" and var.subtype = "bio".) The type of bioclimatic variable to be downloaded. Normal See details

bioclim.number

Used only if downloading bioclimatic variables (var.type = "climatologies" and var.subtype = "bio".)

bioclim.period

Used only if downloading bioclimatic variables (var.type = "climatologies" and var.subtype = "bio".)

bioclim.ssp

Used only if downloading bioclimatic variables (var.type = "climatologies" and var.subtype = "bio".) If the variable is a projected variable, the Shared Socioeconomic Pathway (SSP) scenario to be downloaded. Choices include "ssp126", "ssp245", "ssp370", and "ssp585". Default is NA, which will download historical bioclim data.

bioclim.model

Used only if downloading bioclimatic variables (var.type = "climatologies" and var.subtype = "bio".) If the variable is a projected variable, the climate model chosen to be downloaded. Choices include "gfdl-esm4", "ukesm10-ll", "mpi-esm1-2-hr", "ipslcm6a-lr", and "mriesm2-0" (see technical specifications below for details). Default is NA, which will download historical bioclim data.

mypath

Character. Only required if saving the report to file. A file path to the sub directory where the model output will be stored. Should be used with the file.path() function (i.e. with '/' instead of '\'). If this sub directory does not already exist and should be created by the function, set create.dir = TRUE. This will create a folder from the last part of the filepath in mypath.

create.dir

Logical. Should the last element of mypath create a sub directory for the report? If TRUE, the main folder will be created for the model output. If FALSE (ie, the sub directory already exists), no directory will be created.

save.output

Logical. Should the requested downloads be saved to file? File location specified by mypath.

Value

Returns a spatRaster object of the requested CHELSA climatology or a saved .tif raster file(s). If save.output = FALSE, the rasters will be imported into the R environment directly. If save.output = TRUE, the raster will be saved to the sub directory specified by mypath.

Details

Requires the following packages: "cli", "httr", "terra", "tidyverse", "utils"

See (CHELSA v2.1 Technical Specifications)https://chelsa-climate.org/wp-admin/download-page/CHELSA_tech_specification_V2.pdf for more detail on specific climatologies, including their units, usage, and interpretation.

var.subtype

For the argument var.subtype, the following options are available, depending on the input for var.type: var.type == "daily":

  • "pr" (precipitation amount)

  • "rsds" (Surface downwelling shortwave flux in air)

  • "tas" (mean air temperature)

  • "tasmax" (mean maximum air temperature)

  • "tasmin" (mean minimum air temperature)

var.type == "monthly":

  • "clt"

  • "cmi" (climatic moisture index)

  • "hurs" (near surface relative humidity)

  • "pet" (potential evapotranspiration)

  • "pr" (precipitation amount)

  • "rsds" (Surface downwelling shortwave flux in air)

  • "sfcWind" (Near-surface wind speed)

  • "tas" (mean air temperature)

  • "tasmax" (mean maximum air temperature)

  • "tasmin" (mean minimum air temperature)

  • "vpd" (vapor pressure deficit)

var.type == "climatologies":

  • "ai" (aridity index)

  • "bio" (bioclimatic variables)

  • "clt"

  • "cmi" (climatic moisture index)

  • "hurs" (near surface relative humidity)

  • "pet" (potential evapotranspiration)

  • "pr" (precipitation amount)

  • "rsds" (Surface downwelling shortwave flux in air)

  • "sfcWind" (Near-surface wind speed)

  • "tas" (mean air temperature)

  • "tasmax" (mean maximum air temperature)

  • "tasmin" (mean minimum air temperature)

  • "vpd" (vapor pressure deficit)

var.period

For the argument var.period, the date range should be formatted differently, depending on the input for var.type:

var.type == "daily": Date format should be "MM_DD_YYYY" for a single date, or c("MM-DD-YYYY", "MM-DD-YYYY") for a range of days.

var.type == "monthly": Date format should be "MM_YYYY" for a single date, or c("MM-YYYY", "MM-YYYY") for a range of months.

var.type == "climatologies": Date format should be a range years. Choices are "1981-2010" (historical data), "2011-2040", "2041-2070", or "2071-2100" (projected data).

bioclim.type

bioclim.number

bioclim.period

Note Please include all quotation marks in above formats

Examples


# download historical bioclimatic variables:
scari::import_chelsa_v2(
var.type = "climatologies",
var.subtype = "bio",
var.period = "1981-2010", # historical data
bioclim.type = "bioclim",
bioclim.number = 1:19, # all bioclimatic variables
bioclim.period = "1981-2010",
bioclim.ssp = NA, # historical data
bioclim.model = NA, # historical data
save.output = FALSE
)
#> Error: 'import_chelsa_v2' is not an exported object from 'namespace:scari'

# download projected bioclimatic variables under climate change:
scari::import_chelsa_v2(
var.type = "climatologies",
var.subtype = "bio",
var.period = "1981-2010", # historical data
bioclim.type = "bioclim",
bioclim.number = 1:19, # all bioclimatic variables
bioclim.period = "1981-2010",
bioclim.ssp = 'ssp126', # historical data
bioclim.model = 'gfdl-esm4', # historical data
save.output = FALSE
)
#> Error: 'import_chelsa_v2' is not an exported object from 'namespace:scari'