Package 'getCRUCLdata'

Title: 'CRU' 'CL' v. 2.0 Climatology Client
Description: Provides functions that automate downloading and importing University of East Anglia Climate Research Unit ('CRU') 'CL' v. 2.0 climatology data, facilitates the calculation of minimum temperature and maximum temperature and formats the data into a data.table object or a 'terra' 'SpatRaster' object. 'CRU' 'CL' v. 2.0 data are a gridded climatology of 1961-1990 monthly means released in 2002 and cover all land areas (excluding Antarctica) at 10 arc minutes (0.1666667 degree) resolution. For more information see the description of the data provided by the University of East Anglia Climate Research Unit, <https://crudata.uea.ac.uk/cru/data/hrg/tmc/readme.txt>.
Authors: Adam H. Sparks [aut, cre] (ORCID: <https://orcid.org/0000-0002-0061-8359>)
Maintainer: Adam H. Sparks <[email protected]>
License: MIT + file LICENSE
Version: 2.0.0
Built: 2026-05-17 06:24:18 UTC
Source: https://github.com/ropensci/getCRUCLdata

Help Index


Add derived temperature values for TMAX and TMIN

Description

Add derived temperature values for TMAX and TMIN

Usage

.add_derived_dt(dt, vars)

Arguments

dt

A data.table object of CRU data containing tmp and dtr in order to calculate tmin and tmax.

vars

A named logical vector.

Value

A data.table with tmin and or tmax cols.


Remove source vars if not requested

Description

If tmin or tmax are requested but tmp or dtr are not requested, this function drops the unrequested vars.

Usage

.drop_source_vars_dt(dt, vars)

Arguments

dt

A data.table object of CRU data containing tmp and dtr in order to calculate tmin and tmax.

vars

A named logical vector.

Value

A data.table with the unrequested var columns removed.


Create a data.table of CRU CL v. 2.0 climatology elements

Description

Automates importing CRU CL v.2.0 climatology data and from either the CRU server or local files and creates a data.table of the data. If requested, minimum and maximum temperature may also be calculated as described in the data readme.txt file and returned.

Usage

read_cru_dt(
  pre = FALSE,
  pre_cv = FALSE,
  rd0 = FALSE,
  tmp = FALSE,
  dtr = FALSE,
  reh = FALSE,
  tmn = FALSE,
  tmx = FALSE,
  sunp = FALSE,
  frs = FALSE,
  wnd = FALSE,
  elv = FALSE,
  x = NULL
)

Arguments

pre

Read precipitation (millimetres/month) and return it, TRUE. Defaults to FALSE.

pre_cv

Read cv of precipitation (percent) and return it, TRUE. Defaults to FALSE. NOTE. Setting this to TRUE will always results in pre being set to TRUE and returned as well.

rd0

Read wet-days (number days with >0.1 millimetres rain per month) and return it, TRUE. Defaults to FALSE.

tmp

Reads temperature (degrees Celsius) and return it, TRUE⁠. Defaults to ⁠FALSE'.

dtr

Read mean diurnal temperature range (degrees Celsius) and return it, TRUE. Defaults to FALSE.

reh

Read relative humidity and return it, TRUE. Defaults to FALSE.

tmn

Calculate minimum temperature values (degrees Celsius) and return it, TRUE. Defaults to FALSE.

tmx

Calculate maximum temperature (degrees Celsius) and return it, TRUE. Defaults to FALSE.

sunp

Read sunshine, percent of maximum possible (percent of day length) and return it, TRUE. Defaults to FALSE.

frs

Read ground-frost records (number of days with ground- frost per month) and return it, TRUE. Defaults to FALSE.

wnd

Read 10 m wind speed (metres/second) and return it, TRUE. Defaults to FALSE.

elv

Read elevation (converted to metres) and return it, TRUE. Defaults to FALSE.

x

An optional local file path where CRU CL v.2.0 .dat.gz files are located. If this is empty, the requested data will automatically be downloaded from the server.

Value

A data.table::data.table object of CRU CL v. 2.0 climatology elements.

Nomenclature and Units

pre

precipitation (millimetres/month)

cv

cv of precipitation (percent)

rd0

wet-days (number days with >0.1 millimetres rain per month)

tmp

mean temperature (degrees Celsius)

dtr

mean diurnal temperature range (degrees Celsius)

reh

relative humidity (percent)

sunp

sunshine (percent of maximum possible (percent of day length))

frs

ground-frost (number of days with ground-frost per month)

wnd

10 metre wind speed (metres/second)

elv

elevation (automatically converted to metres from kilometres)

For more information see the description of the data provided by CRU, https://crudata.uea.ac.uk/cru/data/hrg/tmc/readme.txt

Author(s)

Adam H. Sparks, [email protected]

Source

pre

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_pre.dat.gz

rd0

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_rd0.dat.gz

tmp

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz

dtr

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_dtr.dat.gz

reh

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_reh.dat.gz

sunp

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_sunp.dat.gz

frs

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_frs.dat.gz

wnd

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_wnd.dat.gz, areas originally including Antarctica are removed.

elv

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_elv.dat.gz, values are converted from kilometres to metres.

This package crops all spatial outputs to an extent of ymin = -60, ymax = 85, xmin = -180, xmax = 180.

References

New, Mark, et al. "A high-resolution data set of surface climate over global land areas." Climate research 21.1 (2002): 1-25. https://crudata.uea.ac.uk/cru/data/hrg/tmc/new_et_al_10minute_climate_CR.pdf

See Also

read_cru_rast.

Examples

# Create a data frame of temperature from locally available files in the
# tempdir() directory.
library(fs)

f <- path(path_temp(), "grid_10min_tmp.dat.gz")

download.file(
  url = "https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz",
  destfile = f
)


cru_tmp <- read_cru_dt(tmp = TRUE, x = f)

cru_tmp

# or downloading directly from the CRU server

cru_tmp <- read_cru_dt(tmp = TRUE)

cru_tmp

Create a terra SpatRaster object of CRU CL v. 2.0 climatology elements

Description

Create a terra::SpatRaster object or list of objects from CRU CL 2.0 data.

Usage

read_cru_rast(
  pre = FALSE,
  pre_cv = FALSE,
  rd0 = FALSE,
  tmp = FALSE,
  dtr = FALSE,
  reh = FALSE,
  tmn = FALSE,
  tmx = FALSE,
  sunp = FALSE,
  frs = FALSE,
  wnd = FALSE,
  elv = FALSE,
  x = NULL
)

Arguments

pre

Read precipitation (millimetres/month) and return it, TRUE. Defaults to FALSE.

pre_cv

Read cv of precipitation (percent) and return it, TRUE. Defaults to FALSE. NOTE. Setting this to TRUE will always results in pre being set to TRUE and returned as well.

rd0

Read wet-days (number days with >0.1 millimetres rain per month) and return it, TRUE. Defaults to FALSE.

tmp

Reads temperature (degrees Celsius) and return it, TRUE⁠. Defaults to ⁠FALSE'.

dtr

Read mean diurnal temperature range (degrees Celsius) and return it, TRUE. Defaults to FALSE.

reh

Read relative humidity and return it, TRUE. Defaults to FALSE.

tmn

Calculate minimum temperature values (degrees Celsius) and return it, TRUE. Defaults to FALSE.

tmx

Calculate maximum temperature (degrees Celsius) and return it, TRUE. Defaults to FALSE.

sunp

Read sunshine, percent of maximum possible (percent of day length) and return it, TRUE. Defaults to FALSE.

frs

Read ground-frost records (number of days with ground- frost per month) and return it, TRUE. Defaults to FALSE.

wnd

Read 10 m wind speed (metres/second) and return it, TRUE. Defaults to FALSE.

elv

Read elevation (converted to metres) and return it, TRUE. Defaults to FALSE.

x

An optional local file path where CRU CL v.2.0 .dat.gz files are located. If this is empty, the requested data will automatically be downloaded from the server.

Value

A terra::SpatRaster object.

Nomenclature and Units

pre

precipitation (millimetres/month)

cv

cv of precipitation (percent)

rd0

wet-days (number days with >0.1 millimetres rain per month)

tmp

mean temperature (degrees Celsius)

dtr

mean diurnal temperature range (degrees Celsius)

reh

relative humidity (percent)

sunp

sunshine (percent of maximum possible (percent of day length))

frs

ground-frost (number of days with ground-frost per month)

wnd

10 metre wind speed (metres/second)

elv

elevation (automatically converted to metres from kilometres)

For more information see the description of the data provided by CRU, https://crudata.uea.ac.uk/cru/data/hrg/tmc/readme.txt

Author(s)

Adam H. Sparks, [email protected]

Source

pre

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_pre.dat.gz

rd0

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_rd0.dat.gz

tmp

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz

dtr

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_dtr.dat.gz

reh

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_reh.dat.gz

sunp

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_sunp.dat.gz

frs

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_frs.dat.gz

wnd

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_wnd.dat.gz, areas originally including Antarctica are removed.

elv

https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_elv.dat.gz, values are converted from kilometres to metres.

This package crops all spatial outputs to an extent of ymin = -60, ymax = 85, xmin = -180, xmax = 180.

References

New, Mark, et al. "A high-resolution data set of surface climate over global land areas." Climate research 21.1 (2002): 1-25. https://crudata.uea.ac.uk/cru/data/hrg/tmc/new_et_al_10minute_climate_CR.pdf

See Also

read_cru_rast.

Examples

# Create a data frame of temperature from locally available files in the
# tempdir() directory.
library(fs)

f <- path(path_temp(), "grid_10min_tmp.dat.gz")

download.file(
  url = "https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz",
  destfile = f
)


cru_tmp <- read_cru_rast(tmp = TRUE, x = f)

cru_tmp

# or downloading directly from the CRU server

cru_tmp <- read_cru_rast(tmp = TRUE)

cru_tmp