Download daily precipitation by limiting coordinate values

Hello team, I am trying to download chirps product for only the Horn of Africa by limiting latitude and longitude box of the interest, however, I am not able to come up downloading. If anyone has ever tried and know the way to do so please give me your hands. Here is the code I have tried.

get_chirps <- getCHIRPS( "global", lat= c(3, 15), lon=c(33, 48), format= "netcdf", tres= "daily", sres = 0.25, begin = as.Date("1990-01-01"), end=as.Date("2018-12-31"), dsn = (getwd(), "my_Chirp_data"))

Hi @markos! Welcome!

I don't think the getCHIRPS() function from the package heavyRain has the ability to filter geographically the way you want. You can see all the parameters the function accepts in its documentation (or type ?getCHIRPS at the console to bring up the docs from your installed copy of the package).

getCHIRPS() is limited by how the data provider has chosen to make the data available, which in this case is pre-aggregated into a few regions, and posted online in a series of simple directories, with files named by the dates they cover. You can find out more at the CHIRPS FAQ: http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ

A peek at the source code confirms that getCHIRPS() just uses the parameters you supply to generate a path to a directory and a list of files, then downloads those files.

To elaborate a little bit: while it may not be possible to limit the area of interest to Horn of Africa at the download time it certainly is possible to do so on the downloaded netcdf file itself.

It will require a vector representation of your area of interest (suppose country borders, easily downloaded from Natural Earth or GADM) and a combination of raster::mask() and raster::crop() calls.

The process has been discussed in the folowing post:

2 Likes

Thank you for your explanations. As mentioned my @ jlacko I tied to daily data from 1990-2018 however it was so big. I would like to create a spatial mode (S-mode) data matrix (grid points as column and day as a row). I tried to use stars package but wouldn't work for me. In case if you know the way to do so. Thank you.