Skip to contents

Get daily rainfall from CHIRPS, produced by the Climate Hazards Center (CHC), for points, polygons or an area. The data are read from the CHC server, which is the main source and serves both CHIRPS v3 (default) and CHIRPS v2.

Usage

get_chirps(object, dates, server = "CHC", ...)

# Default S3 method
get_chirps(object, dates, server = "CHC", as.matrix = FALSE, ...)

# S3 method for class 'SpatVector'
get_chirps(object, dates, server = "CHC", as.raster = TRUE, ...)

# S3 method for class 'SpatRaster'
get_chirps(object, dates, server = "CHC", as.raster = TRUE, ...)

# S3 method for class 'SpatExtent'
get_chirps(object, dates, server = "CHC", as.raster = TRUE, ...)

# S3 method for class 'sf'
get_chirps(object, dates, server = "CHC", as.sf = FALSE, ...)

# S3 method for class 'sfc'
get_chirps(object, dates, server = "CHC", as.sf = FALSE, ...)

# S3 method for class 'geojson'
get_chirps(object, dates, server = "CHC", as.geojson = FALSE, ...)

Arguments

object

input, an object of class data.frame (or any other object that can be coerced to data.frame) with longitude and latitude in the first two columns, SpatVector, SpatRaster, SpatExtent, sf, sfc or geojson

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

server

a character, "CHC" (default and recommended) or "ClimateSERV". See the section on servers

...

additional arguments passed to get_chirps_raw and extract. See details

as.matrix

logical, returns a matrix with one row per location and one column per day, named "YYYY-MM-DD"

as.raster

logical, returns an object of class SpatRaster

as.sf

logical, returns an object of class sf

as.geojson

logical, returns an object of class geojson

Value

A data frame of CHIRPS data in the long format, ordered by id and date, or a matrix, raster, sf or geojson object as requested:

id

the index for the rows in object

date

the date of each value

lon

the longitude as provided in object

lat

the latitude as provided in object

chirps

the CHIRPS value in mm

Details

Additional arguments

version: CHIRPS version, "3.0" (default) or "2.0". CHC retires CHIRPS v2 after the December 2026 release

type: CHIRPS v3 product, "rnl" (default) or "sat". See get_chirps_raw

resolution: numeric, resolution of CHIRPS v2, 0.05 (default) or 0.25 degrees

operation: for polygons, the function used to summarise the cells of each polygon on each day

operationvalue
max=0
min=1
median=2
sum=4
average=5 (default value)

Coverage: CHIRPS v3 covers 60°S to 60°N and CHIRPS v2 covers 50°S to 50°N, from 1981 to near present. Final data for a month arrive some weeks after it ends.

Polygons: with sf, SpatVector or geojson polygons, each day is summarised over the cells that touch the polygon, with the function set by operation. The lon and lat columns give the centroid of each polygon.

Messages: each request states what it downloads, here daily rainfall from CHIRPS, with the period, so it is not mistaken for temperature from get_chirts. Set options(chirps.quiet = TRUE) to hide these messages.

Indices: for rainfall indices (dry spells, heavy rain days, intensity) use climatrends::rainfall(). The matrix returned with as.matrix = TRUE is its input, see the examples.

Servers

CHC (default) reads the CHIRPS files from https://data.chc.ucsb.edu through terra. It serves CHIRPS v3 and v2, gives the value of the cell that holds each point, and handles many points and long periods in one call. It is the recommended source.

ClimateSERV is kept for backward compatibility. It serves CHIRPS v2 only, averaged over a small buffer around each point, so its values can differ from the CHC values. It sends several requests per location and is slow for more than a few points. ClimateSERV support for CHIRPS may be removed in a future release. Its extra arguments are dist, the buffer distance around each point, nQuadSegs, the number of segments per buffer quadrant, and operation as above.

SpatVector, SpatRaster and SpatExtent input always uses CHC.

References

Funk, C., Peterson, P., Harrison, L. et al. (2026). Scientific Data, 13, 718.
doi:10.1038/s41597-026-07096-4

Funk C. et al. (2015). Scientific Data, 2, 150066.
doi:10.1038/sdata.2015.66

See also

get_chirps_raw for the rasters, get_chirts for temperature, and the climatrends package for rainfall and temperature indices

Examples

if (FALSE) { # interactive()
library("chirps")
library("terra")

dates = c("2017-12-15", "2017-12-31")
lonlat = data.frame(lon = c(-55.0281, -54.9857), lat = c(-2.8094, -2.8756))

# Case 1: return a data.frame in the long format
r1 = get_chirps(lonlat, dates)

# Case 2: a single day, from the CHIRPS v3 product based on IMERG
r2 = get_chirps(lonlat, "2017-12-15", type = "sat")

# Case 3: return a matrix, one column per day
r3 = get_chirps(lonlat, dates, as.matrix = TRUE)

# Case 4: input SpatVector and return raster
f = system.file("ex/lux.shp", package = "terra")
v = vect(f)
r4 = get_chirps(v, dates, as.raster = TRUE)

# Case 5: input SpatExtent and return a raster within the extent
area = ext(c(-66, -64, -6, -4))
r5 = get_chirps(area, dates)

# Case 6: total rainfall per polygon and day
r6 = get_chirps(v, dates, as.raster = FALSE, operation = 4)

# Case 7: rainfall indices with climatrends
if (requireNamespace("climatrends", quietly = TRUE)) {
  climatrends::rainfall(r3, day.one = dates[1], span = ncol(r3))
}
}