The “NASA Global Precipitation Measurement” (GPM) is a sattelite data product to estimate precipitation on a global scale. More precise we will be using the “Integrated Multi-satellitE Retrievals for GPM” (IMERG) data product which merges, intercalibrates and interpolates data from different satellites. It brings together microwave measurements and IR measurements and calibrates against gauge measurements on the ground. It also brings together data from low-earth-orbit satellites with geosynchronous-earth-orbit satellite data. The low-earth-orbit (leo) satellites can’t measure continuously in one spot but rather have a return period with temporal blindspots in between. Geosynchronous-Earth-orbit (geo) satellites can’t take the passive microwave (PMW) measurements that are possible with leo satellites. To get global coverage without temporal gaps morphing and interpolation between the different data sources is done.
The data product uses data from different satellite programs and generations. Most of them are not under the control of the GPM program. GPM rather uses the best data available from other programs. More infos about the data product can be found in the product description document. It can be downloaded from different sources. Here is a summary on how to download.
creating an account and credential file
We have to save the credentials to your account into a
.netrc file. This file then can be used by wget or R. Here are two sources on how to do that:
There is also a specific descriptions about how to access data with R:
global dataset (no subsetting)
The global dataset can be downloaded from the online archive at https://gpm1.gesdisc.eosdis.nasa.gov/data/GPM_L3/GPM_3IMERGDF.06/. This page basically works like an ftp server where you find a file for every day in the measuring period. You can download those files similar to the way shown for the subregion datasets below.
subregion dataset with OPeNDAP
Data for selected regions can be downloaded via the OPeNDAP data selection form. This tool shows you a url with all the options that you chose. You can take that url and automate the download for your specific region. The only trick is that you have to add the file format into the url as shown below.
You can select variables by ticking the checkbox beside the variable name. In the input fields you put the range of time and the latitude and longitude you want to download. The inputs work with the scheme
[from:step:to]. Since the dataset is produced in 0.1° intervals, longitude ranges from 0 to 3599 (\(360\cdot 10-1\)) and latitude from 0 to 1799 (\(180\cdot 10-1\)). Hence to select a subset from longitude 90 to 120 you write the input as
[900:1:1200]. If you want a resulution of only 1° instead of 0.1° you can set the input to
The following shows how to use the url as a template for assembling a download url from latitude and longitude range and a date
We can now download the data with the
GET() function of the httr package. We give the function the paths to the
.netrc file we created earlier.
If we get a response status 200 all went well. Status 400 means that something is wrong with our credentials.
opendapr R package
A more convenient way of downloading opendap data is the opendapr package. To install it we have to execute the following:
Let’s load the package and start working with it:
We have to set our credentials and call the
In order to query data we need a bounding box. We will use the
getbb() function of the osmdata package which enables us to get bounding boxes by searching for a country name, county name or city name for example.
As you see we have to convert the bounding box multple times to get it in the right format that the
odr_get_url() function of the opendapr package requires. We also have to define a time range:
Now we have the urls that we can use to download data with the
To validate that we can read the data we just downloaded we use the stars and the ncmeta package. According to my tests the
read_ncdf() function is the only one that reads the netCDF files with latitude and longitude in the right order. Functions from the terra or raster package don’t realize that latitude and longitude have to be read in reverse order in this case. QGis also reads the files rotated.
First let’s test the global file:
Note that we set the coordinate system to WGS84 since the file does not contain a crs.
We now can plot the dataset:
A more convenient plotting function can be found in the tmap package:
Next we work with the subregion dataset that we downloaded with the opendapr package:
The bounding box of the downloaded file is slightly different from what we set in the bounding box:
Plot with tmap: