R/create_CRU_stack.R
create_CRU_stack.RdThis function automates importing CRU CL v. 2.0 climatology data into R from locally available data files and creates a list of raster stacks of the data. If requested, minimum and maximum temperature may also be automatically calculated as described in the data readme.txt file. This function can be useful if you have network connection issues that mean automated downloading of the files using R does not work properly. In this instance it is recommended to use an FTP client (e.g., FileZilla), web browser or command line command (e.g., wget or curl) to download the files, save locally and use this function to import the data into R.
Nomenclature and units from readme.txt:
precipitation (millimetres/month)
wet-days (number days with >0.1mm rain per month)
mean temperature (degrees Celsius)
mean diurnal temperature range (degrees Celsius)
relative humidity (percent)
sunshine (percent of maximum possible (percent of day length))
ground-frost (number of days with ground-frost per month)
10 metre windspeed (metres/second)
elevation (automatically converted to metres)
For more information see the description of the data provided by CRU, https://crudata.uea.ac.uk/cru/data/hrg/tmc/readme.txt
create_CRU_stack(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, dsn = "")
| pre | Logical. Create a raster stack of precipitation (millimetres/month) from local files? Defaults to FALSE. |
|---|---|
| pre_cv | Logical. Create a raster stack of cv of precipitation (percent) from local files? Defaults to FALSE. |
| rd0 | Logical. Logical. Create a raster stack of wet days (number days with >0.1 millimetres rain per month) from local files? Defaults to FALSE. |
| tmp | Logical. Create a raster stack of temperature (degrees Celsius) from local files? Defaults to FALSE. |
| dtr | Logical. Create a raster stack of mean diurnal temperature range (degrees Celsius) from local files? Defaults to FALSE. |
| reh | Logical. Create a raster stack of relative humidity from local files? Defaults to FALSE. |
| tmn | Logical. Calculate minimum temperature values (degrees Celsius) and return it in a raster stack? Requires tmp and dtr files to be locally present. Defaults to FALSE. |
| tmx | Logical. Calculate maximum temperature values (degrees Celsius) and return it in a raster stack? Requires tmp and dtr files to be locally present. Defaults to FALSE. |
| sunp | Logical. Create a raster stack of sunshine, percent of maximum possible (percent of day length) from local files? Defaults to FALSE. |
| frs | Logical. Create a raster stack of ground-frost records (number of days with ground-frost per month) from local files? Defaults to FALSE. |
| wnd | Logical. Create a raster stack of 10m wind speed (metres/second) from local files? Defaults to FALSE. |
| elv | Logical. Create a raster layer of elevation (converted to metres) from local files? Defaults to FALSE. |
| dsn | Local file path where CRU CL v. 2.0 .dat.gz files are located. |
A list of raster
stack objects of CRU CL v. 2.0 climatology elements
This package automatically converts elevation values from kilometres to metres.
This package crops all spatial outputs to an extent of ymin = -60, ymax = 85, xmin = -180, xmax = 180. Note that the original wind data include land area for parts of Antarctica, these data are excluded in the raster stacks generated by this function.
# Create a raster stack of precipitation and temperature from pre and tmp # files in the Downloads directory.# NOT RUN { CRU_pre_tmp <- create_CRU_stack(pre = TRUE, tmp = TRUE, dsn = "~/Downloads") # }