Skip to contents

This function downloads historic worldclim version 2.1 and processes it according to the specified parameters. It supports various climate variables and resolutions, and can clip the downloaded data to a specified area of interest (AOI). The function is designed to handle download issues with retry logic and customizable timeouts.

Usage

get_worldclim_historic(
  var = "bio",
  res = 10,
  aoi = NULL,
  retries = 3,
  timeout = 300
)

Arguments

var

A character string specifying the climate variable to download. Possible values are: .

  • "tavg": Average temperature

  • "tmin": Minimum temperature

  • "tmax": Maximum temperature

  • "prec": Precipitation

  • "srad": Solar radiation

  • "wind": Wind speed

  • "vapr": Vapor pressure

  • "bio": Bioclimatic variables

res

A numeric value indicating the resolution of the data. Valid options are:

  • 0.5: 30 arc-seconds (~1 km)

  • 2.5: 2.5 arc-minutes (~5 km)

  • 5: 5 arc-minutes (~10 km)

  • 10: 10 arc-minutes (~20 km)

aoi

A spatial object representing the area of interest. Can be an `sf` or `terra` vector.

retries

An integer specifying the number of times to retry the download if it fails. Default is 3.

timeout

A numeric value specifying the maximum time (in seconds) to wait for a server response. Default is 300 seconds.

Value

A `SpatRaster` object containing the downloaded climate data, clipped to the specified AOI.

References

Fick, Stephen E., and Robert J. Hijmans. "WorldClim 2: new 1-km spatial resolution climate surfaces for global land areas." International journal of climatology 37.12 (2017): 4302-4315.doi:10.1002/joc.5086

Examples

if (FALSE) { # \dontrun{
library(sf)
library(terra)

nc <- st_read(system.file("shape/nc.shp", package="sf"))
nc <- st_transform(nc, crs = 4326)

climate_historic <- get_worldclim_historic(var =
 "tmin", res = 5, aoi = nc)
 } # }