_verified_ Download Chirps Data In R 【Chrome】
If you need the raw NetCDF or GeoTIFF files for an entire year or the whole globe, you can bypass R packages and use R's download.file to grab files from the official CHG FTP server .
If you have a set of coordinates (e.g., weather stations or farm locations), you can extract daily rainfall directly into a data frame.
# Install and load the package install.packages("chirps") library(chirps) # Define your points of interest lonlat <- data.frame(lon = c(-55.02, -54.98), lat = c(-2.80, -2.87)) # Define the date range dates <- c("2023-01-01", "2023-01-31") # Fetch data from the Climate Hazards Center (CHC) server # Use server = "ClimateSERV" for small requests ( Use code with caution. Extraction for Spatial Areas (Rasters) download chirps data in r
High-performance computing or when you need global daily data for multi-decadal analysis. Summary of Methods Ease of Use chirps package Specific points or small AOIs High (subsetting) ⭐⭐⭐⭐⭐ pRecipe package Bulk regional/global downloads ⭐⭐⭐⭐ Direct FTP Downloading entire years/global maps Slow (initial) Common Troubleshooting Package chirps - CRAN
library(terra) library(sf) # Define a bounding box or load a shapefile aoi <- st_bbox(c(xmin = 34, xmax = 35, ymin = -1, ymax = 0), crs = 4326) # Download as a raster stack rain_raster <- get_chirps(aoi, dates, as.raster = TRUE) plot(rain_raster[[1]]) Use code with caution. 2. Using the pRecipe Package If you need the raw NetCDF or GeoTIFF
To download a raster for a specific region, you can pass a SpatVector (from the terra package) or an sf object to the get_chirps function.
# Install pRecipe install.packages("pRecipe") library(pRecipe) # Download monthly CHIRPS data for a specific year download_chirps( folder_path = "./data/chirps", domain = "land", # Land-only or "global" time_res = "monthly" # "daily", "monthly", or "yearly" ) Use code with caution. 3. Alternative: Direct Download via FTP Summary of Methods Ease of Use chirps package
ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CHIRPS-2.0/