Get daily temperature from the Climate Hazards Center (CHC) for points, polygons or an area. Two products are available. CHIRTS-daily (default) covers 1983 to 2016 and has maximum and minimum temperature, relative humidity and heat index. CHIRTS-ERA5 extends maximum and minimum temperature from 1980 to near present.
Usage
get_chirts(object, dates, var, ...)
# Default S3 method
get_chirts(object, dates, var, as.matrix = FALSE, ...)
# S3 method for class 'SpatVector'
get_chirts(object, dates, var, as.raster = TRUE, ...)
# S3 method for class 'SpatRaster'
get_chirts(object, dates, var, as.raster = TRUE, ...)
# S3 method for class 'SpatExtent'
get_chirts(object, dates, var, as.raster = TRUE, ...)Arguments
- object
an object of class
data.frame(or any other object that can be coerced to adata.frame) with longitude and latitude in the first two columns,sfpoints,SpatVector,SpatRasterorSpatExtent- dates
a character or Date vector "YYYY-MM-DD", with one date for a single day or two dates for the start and end of the period
- var
character, A valid variable from the options: “Tmax”, “Tmin”, “RHum” and “HeatIndex”. CHIRTS-ERA5 has “Tmax” and “Tmin” only
- ...
further arguments passed to
get_chirts_rawandextract. See details- as.matrix
logical, returns a
matrixwith one row per location and one column per day, named "YYYY-MM-DD"- as.raster
logical, returns an object of class
SpatRaster
Value
A data frame in the long format, ordered by id and
date, with the value in the column chirts. A SpatRaster
if as.raster = TRUE, or a matrix with one column per day, named
"YYYY-MM-DD", if as.matrix = TRUE
Details
Variable description from https://data.chc.ucsb.edu/products/CHIRTS/daily/aaa.Readme.txt
- Tmax
Daily average maximum air temperature at 2 m above ground
- Tmin
Daily average minimum air temperature at 2 m above ground
- RHum
Daily average relative humidity
- HeatIndex
Daily average heat index
Additional arguments
product: “CHIRTS-daily” (default, 1983 to 2016) or “CHIRTS-ERA5” (1980 to near present, Tmax and Tmin)
operation: for polygons, the function used to summarise the cells
of each polygon on each day, with the codes listed in
get_chirps (average by default)
Coverage: both products cover 60°S to 70°N.
Messages: each request states what it downloads, here daily
temperature or humidity from CHIRTS, with the period, so it is not
mistaken for rainfall from get_chirps. Set
options(chirps.quiet = TRUE) to hide these messages.
Indices: for temperature indices (growing degree days, crop
sensitive indices, frost and heat days) use the climatrends
package, which takes the matrices returned with as.matrix = TRUE.
Examples
if (FALSE) { # interactive()
library("chirps")
library("terra")
# Case 1: input a data frame return a data frame in the long format
dates = c("2010-12-15","2010-12-31")
lonlat = data.frame(lon = c(-55.0281,-54.9857),
lat = c(-2.8094, -2.8756))
temp1 = get_chirts(lonlat, dates, var = "Tmax")
# Case 2: input a data frame return a matrix
temp2 = get_chirts(lonlat, dates, "Tmax", as.matrix = TRUE)
# Case 3: recent dates from CHIRTS-ERA5
temp3 = get_chirts(lonlat, c("2024-01-01", "2024-01-31"), var = "Tmin",
product = "CHIRTS-ERA5")
# Case 4: input a SpatVector and return raster
f = system.file("ex/lux.shp", package="terra")
v = vect(f)
temp4 = get_chirts(v, dates, var = "Tmax", as.raster = TRUE)
# Case 5: average per polygon and day
temp5 = get_chirts(v, dates, var = "Tmax", as.raster = FALSE)
# Case 6: indices with climatrends
if (requireNamespace("climatrends", quietly = TRUE)) {
tmin = get_chirts(lonlat, dates, var = "Tmin", as.matrix = TRUE)
temp = array(c(temp2, tmin), dim = c(dim(temp2), 2),
dimnames = list(NULL, colnames(temp2), NULL))
climatrends::temperature(temp, day.one = dates[1], span = ncol(temp2))
}
}
