Skip to contents

Get daily precipitation data from the "Climate Hazards Group". Two server sources are available. The first, "CHC" (default) is recommended for multiple data-points, while "ClimateSERV" is recommended when few data-points are required (~ 50).

Usage

get_chirps(
  object,
  dates,
  server,
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  ...
)

# Default S3 method
get_chirps(
  object,
  dates,
  server,
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.matrix = FALSE,
  ...
)

# S3 method for class 'SpatVector'
get_chirps(
  object,
  dates,
  server = "CHC",
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.raster = TRUE,
  ...
)

# S3 method for class 'SpatRaster'
get_chirps(
  object,
  dates,
  server = "CHC",
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.matrix = TRUE,
  as.raster = TRUE,
  ...
)

# S3 method for class 'SpatExtent'
get_chirps(
  object,
  dates,
  server = "CHC",
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.raster = TRUE,
  ...
)

# S3 method for class 'sf'
get_chirps(
  object,
  dates,
  server,
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.sf = FALSE,
  ...
)

# S3 method for class 'geojson'
get_chirps(
  object,
  dates,
  server,
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.geojson = FALSE,
  ...
)

# S3 method for class 'SpatExtent'
get_chirps(
  object,
  dates,
  server = "CHC",
  dataset_version = "2.0",
  dataset_type = c("rnl", "sat"),
  as.raster = TRUE,
  ...
)

Arguments

object

input, an object of class data.frame (or any other object that can be coerced to data.frame), SpatVector, SpatRaster, sf or geojson

dates

a character of start and end dates in that order in the format "YYYY-MM-DD"

server

a character that represents the server source "CHC" or "ClimateSERV"

dataset_version

dataset version (character/string) . See default.

dataset_type

dataset type (character/string) , only dirst elemet is considered. See default and https://data.chc.ucsb.edu/products/CHIRPS/v3.0/daily/final/readme.txt.

...

additional arguments passed to terra or sf methods See details

as.matrix

logical, returns an object of class matrix

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 matrix, raster or a data frame of CHIRPS data:

id

the index for the rows in object

dates

the dates from which CHIRPS was requested

lon

the longitude as provided in object

lat

the latitude as provided in object

chirps

the CHIRPS value in mm

Details

Data description at https://data.chc.ucsb.edu/products/CHIRPS-2.0/README-CHIRPS.txt

Additional arguments when using server = "CHC"

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

Additional arguments when using server = "ClimateSERV"

dist: numeric, buffer distance for each object coordinate

nQuadSegs: integer, number of segments per buffer quadrant

operation: supported operations for ClimateSERV are:

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

Note

get_chirps() may return some warning messages given by sf, please look sf documentation for possible issues.

### examplesIf interactive()

References

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

Climate Hazards Center Infrared Precipitation with Stations version 3. CHIRPS3 Data Repository https://doi.org/10.15780/G2JQ0P (2025). Data was accessed on 2026 01 28. https://www.chc.ucsb.edu/data/chirps3,
doi:10.15780/G2JQ0P

Examples

library("chirps")
library("terra")
#> terra 1.8.93

# Case 1: return as a data.frame
dates = c("2017-12-15","2017-12-31")
lonlat = data.frame(lon = c(-55.0281,-54.9857), lat = c(-2.8094, -2.8756))

r1 = get_chirps(lonlat, dates, server = "CHC")
#> 
#> Fetching data as GeoTIFF files from CHC server 
#> 
#> Getting CHIRPS in a .05 deg resolution 

# Case 2: return a matrix
r2 = get_chirps(lonlat, dates, server = "CHC", as.matrix = TRUE)
#> 
#> Fetching data as GeoTIFF files from CHC server 
#> 
#> Getting CHIRPS in a .05 deg resolution 

# Case 3: input SpatVector and return raster
f = system.file("ex/lux.shp", package = "terra")
v = vect(f)
r3 = get_chirps(v, dates, server = "CHC", as.raster = TRUE)
#> 
#> Fetching data as GeoTIFF files from CHC server 
#> 
#> Getting CHIRPS in a .05 deg resolution 

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

dates = c("2017-12-15", "2017-12-31")

r4 = get_chirps(area, dates, server = "CHC")
#> 
#> Fetching data as GeoTIFF files from CHC server 
#> 
#> Getting CHIRPS in a .05 deg resolution 

# Case 5: using the server "ClimateSERV"
r5 = get_chirps(lonlat, dates, server = "ClimateSERV")
#> 
#> Fetching data from ClimateSERV 
#> 
#> Getting your request...

# Case 6: from "ClimateSERV" and return as a matrix
r6 = get_chirps(lonlat, dates, server = "ClimateSERV", as.matrix = TRUE)
#> 
#> Fetching data from ClimateSERV 
#> 
#> Getting your request...

# Case 7 (4b): input SpatExtent and return a raster within the extent (CHIRPS dataset version 3.0)
area = ext(c(-66, -64, -6, -4))

dates = c("2017-12-15", "2017-12-31")

r7 = r4b <- get_chirps(area, dates, server = "CHC",dataset_version="3.0")
#> 
#> Fetching data as GeoTIFF files from CHC server 
#> 
#> Information about 'rnl' and 'sat' data directories
#> 
#> CHIRPS is fundamentally a pentad and monthly product. 
#> All other time-steps are derived from those. 
#> Downscaling to daily data requires some other information 
#> on the day to day changes in precipitation data.
#> 
#> Here we provide two different ways of downscaling CHIRPS-v3 to daily values. 
#> Depending on the application, either version might be preferable.
#> 
#> The identifiers 'rnl' and 'sat' represent the type of data used for disaggregation: 
#> 	A reanalysis dataset and a satellite dataset. 
#> 
#> 	rnl uses daily precipitation from the ECMWF ERA Reanalysis v5 (ERA5) data product 
#> 		to partition pentadal CHIRPS-v3 precipitation totals into daily amounts.
#> 
#> 	sat uses daily precipitation from the NASA IMERG Late V07 data product (IMERG) 
#> 		to partition pentadal CHIRPS-v3 precipitation totals into daily amounts.
#> 
#> In each case, the daily IMERG or ERA5 data are converted to ratios of the corresponding pentad total. 
#> These daily ratios are multiplied by the CHIRPS3 pentad total to produce daily CHIRPS3 estimates. 
#> When the ERA5 or IMERG pentad totals are zero, and the CHIRPS3 total is not, 
#> the CHIRPS3 total is divided evenly amongst the days.
#> 
#> Input data characteristics:
#> 
#> IMERG has 0.1 degree spatial resolution, compared to 0.25 degree for ERA5.
#> The IMERG does not begin until 1998, the ERA5 covers the whole time period. 
#> IMERG is available within the 2-day lag for making preliminary CHIRPS.  The ERA5 has a 5-6 day lag, so daily CHIRPS prelim would be delayed. 
#> For now the prelim daily CHIRPS is only done with the IMERG data. The CHIRP-v3 daily downscaling is also done with IMERG.
#> 
#> 
#> Getting CHIRPS in a .05 deg resolution 

r8 = r4c <- get_chirps(area, dates, server = "CHC",dataset_version="3.0",dataset_type="sat")
#> 
#> Fetching data as GeoTIFF files from CHC server 
#> 
#> Information about 'rnl' and 'sat' data directories
#> 
#> CHIRPS is fundamentally a pentad and monthly product. 
#> All other time-steps are derived from those. 
#> Downscaling to daily data requires some other information 
#> on the day to day changes in precipitation data.
#> 
#> Here we provide two different ways of downscaling CHIRPS-v3 to daily values. 
#> Depending on the application, either version might be preferable.
#> 
#> The identifiers 'rnl' and 'sat' represent the type of data used for disaggregation: 
#> 	A reanalysis dataset and a satellite dataset. 
#> 
#> 	rnl uses daily precipitation from the ECMWF ERA Reanalysis v5 (ERA5) data product 
#> 		to partition pentadal CHIRPS-v3 precipitation totals into daily amounts.
#> 
#> 	sat uses daily precipitation from the NASA IMERG Late V07 data product (IMERG) 
#> 		to partition pentadal CHIRPS-v3 precipitation totals into daily amounts.
#> 
#> In each case, the daily IMERG or ERA5 data are converted to ratios of the corresponding pentad total. 
#> These daily ratios are multiplied by the CHIRPS3 pentad total to produce daily CHIRPS3 estimates. 
#> When the ERA5 or IMERG pentad totals are zero, and the CHIRPS3 total is not, 
#> the CHIRPS3 total is divided evenly amongst the days.
#> 
#> Input data characteristics:
#> 
#> IMERG has 0.1 degree spatial resolution, compared to 0.25 degree for ERA5.
#> The IMERG does not begin until 1998, the ERA5 covers the whole time period. 
#> IMERG is available within the 2-day lag for making preliminary CHIRPS.  The ERA5 has a 5-6 day lag, so daily CHIRPS prelim would be delayed. 
#> For now the prelim daily CHIRPS is only done with the IMERG data. The CHIRP-v3 daily downscaling is also done with IMERG.
#> 
#> 
#> Getting CHIRPS in a .05 deg resolution