Given a dataframe with longitude and latitude coordinates, extracts rainfall and temperature data from Worldclim. Rasters are downloaded if not provided.

get_climate_vars(data, vars = NULL, output = c("monthly", "annual"))

aggregate_clim(cl, funs = c("mean", "quantile"), probs = c(0.05, 0.95))

annualize_clim(cl)

Arguments

data

Dataframe with columns latitude and longitude.

vars

Vector of climate variables to be extracted; see Details.

output

Either 'monthly' (default), or 'annual', in which case the annualize function is executed on the result. Alternatively you can generate monthly output, and use annualize_clim yourself (see Examples).

cl

Output of get_climate_vars.

funs

For aggregate_clim, a character vector of functions to be applied to each column.

probs

For aggregate_clim, if 'quantile' is one of the functions, the probabilities to be calculated (see quantile)

Details

The climate variables are any of the Worldclim 2.0 variables, including "tmin","tmax","tavg","prec","srad","wind","vapr". Also allowed is 'pet', which will be extracted from the Zomer PET database (see get_zomer_pet).

Examples

# NOT RUN {
# First set the path to where WorldClim layers will be downloaded,
# and if extracting PET, where you downloaded the Zomer PET database
# see ?get_zomer_pet
options(worldclimpath="/path/to/worldclim")
res <- get_climate_vars(data=data.frame(longitude=150, latitude=-33), vars=c("tmin","bio"))

# To extract PET, first set the path to where the layers were downloaded
options(zomerpetpath="c:/data/zomer")
res <- get_climate_vars(data=data.frame(longitude=150, latitude=-33), vars=c("pet","tavg"))

# By default all monthly values are returned, use annualize to get annual
# averages (or total in case of MAP):
annualize(res)

# ... or simply use output="annual"
res <- get_climate_vars(data=data.frame(longitude=150, latitude=-33),
vars=c("pet","tavg"), output="annual")
# }