English

Monthly Rainfall Data for Any City, Free with R and CHIRPS (Script Generator + Climate Type Tool)

Climatecharts.net stops in 2022. Recent monthly rainfall for almost any city can be downloaded free with R and CHIRPS v3. The tool in this guide writes the R script, then classifies the climate by Schmidt-Ferguson and Oldeman.

Monthly Rainfall Data for Any City, Free with R and CHIRPS (Script Generator + Climate Type Tool)
Contents
  1. How is the script generator used?
  2. Why not use other rainfall sources?
  3. What is CHIRPS and how reliable is it?
  4. How does the R script work?
  5. Stage 1: installing the packages
  6. Stage 2: locations and period
  7. Stage 3: downloading month by month with progress
  8. Stages 4 and 5: monthly totals and export
  9. How recent is CHIRPS data?
  10. How can a climate type be derived from monthly rainfall?
  11. Worked example
  12. How should CHIRPS be cited in a thesis or paper?
  13. Frequently asked questions
  14. Can CHIRPS be used for locations outside Indonesia?
  15. How long does a 10-year download take?
  16. Why does the download stop with the message Please check your dates?
  17. How many years of data are needed for Schmidt-Ferguson and Oldeman classification?
  18. Is Rtools required on Windows?
  19. Do CHIRPS values match station records?
  20. References

Short answer: recent monthly rainfall data (up to the last complete month) for almost any city between 60°N and 60°S can be downloaded free of charge with the R package chirps, which reads CHIRPS v3 from the Climate Hazards Center. The data arrive as daily values on a 0.05° grid (about 5 km), are summed into monthly totals, and are saved to Excel and CSV. The tool below writes the complete R script for any list of locations and any period.

Many students and analysts rely on climatecharts.net for quick rainfall summaries. The site is convenient: a location is selected, a climate diagram appears, and the numbers can be exported. However, its record currently ends in 2022. Consequently, a request for monthly rainfall in Medan, Pematang Siantar, and Asahan (North Sumatra, Indonesia) for 2025 and 2026 could not be met from that source, and an R workflow based on CHIRPS was built instead. The generator below packages that workflow so that it works for any city.

Quick route without the tool: install the R packages sf, terra, chirps, and writexl; build a data frame with columns lon and lat (longitude first); call get_chirps() one month at a time; sum the daily values by location, year, and month; and export the table with write_xlsx().

How is the script generator used?

Each line of the location box holds one site in the pattern name; latitude, longitude, for example Nairobi; -1.2864, 36.8172. Coordinates come from Google Maps: a right-click on the map shows the latitude and longitude, and a click on those numbers copies them. Google Maps lists latitude first, whereas the chirps package expects longitude first. The generator swaps the order automatically, which removes the most common error in hand-written scripts.

After the locations and the first and last months are entered, the tool reports four figures: (1) the number of months and days requested; (2) the estimated download time; (3) the number of output rows (locations × months); and (4) the most recent month that is likely to be complete. The time estimate rests on a test run in which three locations over 21 months finished in 31.4 minutes, or roughly 1 to 1.5 minutes per month. Thus, a 21-month request shows an estimate of 21 to 32 minutes. The Download R script button saves a ready-to-run .R file; opening it in RStudio and clicking Source starts the process.

Why not use other rainfall sources?

Several alternatives were checked before CHIRPS was chosen. The comparison below reflects their status at the end of November 2026 for the North Sumatra case.

SourceFindingNote
climatecharts.netRecord ends in 2022Convenient climate diagrams, but not yet updated
Statistics Indonesia (BPS) WebAPI, MedanMonthly rainfall only for 2013, 2018, and 2019Official station data, but not continuous
BMKG weather map servicesForecasts, warnings, and hotspots; the satellite rainfall layer requires a tokenNo public archive of historical rainfall
National weather service station archivesOfficial daily gauge dataUsually require registration or a formal request
CHIRPS v3 (via R)1981 to near present, daily, 0.05°Free, no registration, fully repeatable

The pattern is consistent: the obstacle is rarely a total absence of data, but rather continuity and open access. Station records from national weather services remain the official reference, yet obtaining them takes time. Thus, CHIRPS is a realistic choice for coursework, preliminary analysis, and filling gaps between stations.

What is CHIRPS and how reliable is it?

CHIRPS (Climate Hazards Center InfraRed Precipitation with Station data) is a gridded rainfall dataset produced by the Climate Hazards Center at the University of California, Santa Barbara. Version 3 blends infrared satellite rainfall estimates with ground station observations at 0.05° resolution, covers land between 60°N and 60°S, and runs from 1981 to near present. The dataset is widely used for drought monitoring, food security early warning, and agricultural research in the tropics. It is also in the public domain, so the only obligation is to cite it.

Consider an agribusiness student in Kisaran, North Sumatra, who is writing a methods chapter. The oil palm and rice fields under study are far from any weather station, so the record from the Medan station may not represent rainfall at the study site. In this situation, a gridded product such as CHIRPS is an advantage rather than a compromise: every cell of roughly 5 × 5 km carries its own rainfall value, including areas with no gauge at all.

However, CHIRPS remains an estimate, not a direct measurement. The value in one grid cell can differ from the gauge record at the same point, particularly during intense, highly local storms. Consequently, a methods section should name the data source explicitly and, where possible, compare it with the nearest station record.

How does the R script work?

The only requirements are R and RStudio (both free) and a stable internet connection. The script runs in five stages: installing packages, defining locations and the period, downloading month by month, summing to monthly totals, and exporting the results. Variable names in the script are in Indonesian (lokasi = locations, bulan = month, tahun = year), while comments and progress messages are in English.

Stage 1: installing the packages

options(timeout = 1200)
perlu <- c("sf", "terra", "chirps", "writexl")
belum <- perlu[!perlu %in% rownames(installed.packages())]
if (length(belum) > 0) {
  install.packages(belum, repos = "https://cloud.r-project.org", type = "binary")
}

The line options(timeout = 1200) matters. The sf and terra packages required by chirps are tens of megabytes, whereas the default download limit in R is 60 seconds. In the first test run, installation failed with Timeout of 60 seconds was reached, which then cascaded into could not find function errors. A warning about Rtools may also appear on Windows; it can be ignored because the packages are installed as precompiled binaries.

Stage 2: locations and period

lokasi <- data.frame(
  nama = c("Medan", "Pematang Siantar", "Asahan (Kisaran)"),
  lon  = c(98.6722, 99.0687, 99.6158),
  lat  = c(3.5952, 2.9595, 2.9845)
)
bulan_awal  <- "2025-01-01"
bulan_akhir <- "2026-09-01"

This block is the only part that changes between projects, and it is exactly what the generator writes. Any number of locations can be listed, and the period can start as early as January 1981.

Stage 3: downloading month by month with progress

The function get_chirps() retrieves one file per day, so a 21-month period means more than 600 files. Rather than requesting everything at once, the script splits the work into months, prints progress, and saves each month to a folder named chirps_cache. Each failed month is retried up to three times before it is skipped.

RStudio console while the R script downloads CHIRPS rainfall data month by month, with the first month completed in 90 seconds
RStudio during the test run: January 2025 finished in 90 seconds before the script moved to February 2025 (progress messages in the Indonesian version of the script).

If the connection drops or RStudio closes, the same script is simply run again. Months already stored in the cache are reported as skipped, and downloading resumes from the first missing month. Thus, a long request can be completed across several sessions without starting over.

Stages 4 and 5: monthly totals and export

hujan_bulanan <- aggregate(cbind(curah_hujan_mm = chirps, hari_hujan) ~ lokasi + tahun + bulan,
                           data = hujan_harian, FUN = sum)
write_xlsx(hujan_bulanan, "curah_hujan_bulanan_chirps_2025_2026.xlsx")

Daily values are summed into monthly rainfall (mm per month), and the number of rain days (days with at least 1 mm) is counted at the same time. This step deliberately uses base R instead of dplyr: during testing, dplyr failed to load after an interrupted installation and produced could not find function “bind_rows”. The final table for the example has 63 rows (3 locations × 21 months) with the columns location, year, month, rainfall in millimeters, and rain days.

How recent is CHIRPS data?

CHIRPS v3 is released with a lag of several weeks. On 25 November 2026, the chirps package reported data available up to about 11 October 2026. When the requested end date exceeds the release, R stops with Please check your dates and prints the last available date.

The practical consequence is that the final month is often incomplete. An October total built from only 11 days is far below the true value and cannot be compared with other months. Consequently, the script requests complete months only, and the generator flags any end month that is probably not yet complete. When the next month is released, the end month is moved forward and the script is run again; only the new month is downloaded.

How can a climate type be derived from monthly rainfall?

Once a monthly table exists, a common next step in agricultural and geographic studies in Indonesia and Southeast Asia is to classify the climate. Two rainfall-only systems dominate there: Schmidt-Ferguson and the Oldeman agroclimatic zones. Both need nothing more than monthly totals, so the CHIRPS output can be used directly. The curah_hujan_mm column for one location (sorted by year, then month) can be pasted into the tool below.

Quick route without the tool: for Schmidt-Ferguson, count dry months (below 60 mm) and wet months (above 100 mm) in each year, then Q = mean dry months ÷ mean wet months × 100%. For Oldeman, use the long-term mean of each calendar month: wet above 200 mm, dry below 100 mm, counted as consecutive months.

In the Schmidt-Ferguson system, every month of every year is labeled dry (below 60 mm), humid (60 to 100 mm), or wet (above 100 mm). The counts of dry and wet months are averaged per year, and Q = mean dry months ÷ mean wet months × 100%. The type is A when Q is below 14.3%, B for 14.3 to 33.3%, C for 33.3 to 60%, D for 60 to 100%, E for 100 to 167%, F for 167 to 300%, G for 300 to 700%, and H for 700% or more.

Oldeman uses stricter thresholds because it was designed around the water needs of lowland rice: a wet month exceeds 200 mm and a dry month falls below 100 mm, judged on the mean of each calendar month. The main zone depends on consecutive wet months (A more than 9, B 7 to 9, C 5 to 6, D 3 to 4, E fewer than 3), and the subzone depends on consecutive dry months (1 fewer than 2, 2 for 2 to 3, 3 for 4 to 6, 4 more than 6). The tool counts runs cyclically, so December connects to January.

Worked example

The default input contains two years of illustrative numbers, not data for a real city. The first year has no dry month and 11 wet months; the second has one dry month (July, 55 mm) and 10 wet months. The means are therefore 0.5 dry and 10.5 wet months per year, so Q = 0.5 ÷ 10.5 × 100% = 4.8%, which is type A (very wet).

For Oldeman, the two-year means give October (270 mm), November (310 mm), December (340 mm), and January (300 mm) as four consecutive wet months; February and September average 195 mm each and therefore do not qualify. The consecutive dry months are June (95 mm) and July (75 mm). The result is zone D2. The example reveals the dual nature of the two systems: a site can be very wet by Schmidt-Ferguson, yet only moderately favorable for rice by Oldeman, because the Oldeman wet threshold is twice as high.

Both classifications normally require at least 10 years of data, and 30 years is preferable. Thus, two years of CHIRPS data provide only a first look. For a thesis, the generator should be set to a period of a decade or more; the download then takes a few hours, but the cache allows it to be paused and resumed at any time.

How should CHIRPS be cited in a thesis or paper?

The methods section should state that rainfall data came from CHIRPS v3 (Climate Hazards Center), accessed through the R package chirps, at specified coordinates, at 0.05° resolution, and aggregated from daily values to monthly totals. Both the dataset and the package should be cited; the package citation can be printed in R with citation("chirps"). Where a supervisor or reviewer requires official observations, CHIRPS can be positioned as supplementary data for areas without stations, while gauge records are requested from the national weather service.

Frequently asked questions

Can CHIRPS be used for locations outside Indonesia?

Yes. CHIRPS v3 covers land areas between 60°N and 60°S, which includes most of Africa, Latin America, South and Southeast Asia, and Australia. Only the names and coordinates in the location list need to change.

How long does a 10-year download take?

About 2 to 3 hours for 120 months, based on the observed rate of 1 to 1.5 minutes per month. A stable connection helps; if the process stops, running the script again skips the months already saved.

Why does the download stop with the message Please check your dates?

The requested end date is later than the most recent release. Moving the end month back by one month and running the script again solves the problem.

How many years of data are needed for Schmidt-Ferguson and Oldeman classification?

At least 10 years is the usual minimum, and 30 years is preferable. Because CHIRPS starts in 1981, a long period can be requested with the same script by changing the first month in the generator.

Is Rtools required on Windows?

No. The Rtools warning appears because RStudio checks for it automatically, but every package in the script is installed as a precompiled binary that needs no compilation.

Do CHIRPS values match station records?

Not always. CHIRPS is a satellite-based estimate corrected with station data, so a single grid cell can differ from one rain gauge. For research, the source should be stated clearly and compared with the nearest station where one exists.

References

  • Funk, C., Peterson, P., Harrison, L., et al. (2026). Scientific Data, 13, 718. https://doi.org/10.1038/s41597-026-07096-4
  • Funk, C., Peterson, P., Landsfeld, M., et al. (2015). The climate hazards infrared precipitation with stations: a new environmental record for monitoring extremes. Scientific Data, 2, 150066. https://doi.org/10.1038/sdata.2015.66
  • de Sousa, K., Sparks, A. H., Ashmall, W., van Etten, J., & Solberg, S. Ø. (2020). chirps: API client for the CHIRPS precipitation data in R. Journal of Open Source Software, 5(51), 2419. https://doi.org/10.21105/joss.02419
  • Schmidt, F. H., & Ferguson, J. H. A. (1951). Rainfall types based on wet and dry period ratios for Indonesia with Western New Guinea. Verhandelingen No. 42. Djawatan Meteorologi dan Geofisik, Jakarta.
  • Oldeman, L. R. (1975). An agro-climatic map of Java. Contributions of the Central Research Institute for Agriculture, Bogor, No. 17.

How to cite this article: Agung Budi Santoso (2026). Monthly Rainfall Data for Any City, Free with R and CHIRPS (Script Generator + Climate Type Tool). Catatan Budi. https://agungbudisantoso.com/en/monthly-rainfall-data-chirps-r/

Photo of Agung Budi Santoso

Written by

Agung Budi Santoso

Lecturer in Management & Agribusiness · Universitas Sumatera Utara

A lecturer and researcher who turns statistics, econometrics, and agribusiness research methods into practical, step-by-step notes for students and researchers.

Discussion

No comments yet. Have a question about this topic? Write it below and I will do my best to answer.

Leave a comment

Your email address will not be published.