Google Earth Engine Tutorial: Download Rainfall Data 1981-2022
Credit: Youtube Channel “Terra Spatial, Learn how to download long-term rainfall data from 1981 to 2022 for climate studies and analysis.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine (GEE) is a powerful platform for analyzing geospatial data, including global climate datasets like rainfall. This tutorial outlines how to programmatically access and download rainfall data for the period 1981–2022 using GEE.
Step 1: Set Up Your Google Earth Engine Account
Create a GEE account via earthengine.google.com. Install the Earth Engine Python API and authenticate your access using your Google account.
Once authenticated, open the GEE Code Editor and initialize the API with the following snippet:
import ee
ee.Authenticate()
ee.Initialize()
Step 2: Choose a Rainfall Dataset
GEE hosts multiple rainfall datasets. Common options include:
- TRMM (Tropical Rainfall Measuring Mission) (1998–2019)
- GPM (Global Precipitation Measurement) (2000–present)
- CHIRPS (Climate Hazards Group InfraRed Precipitation with Station data) (1981–present)
For the 1981–2022 timeframe, the CHIRPS dataset is ideal. Use the following code to load it:
chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/PENTAD")
Step 3: Define the Area of Interest
Select a region using an ee.Geometry
object or a shapefile. For example:
region = ee.Geometry.Rectangle([longitude_min, latitude_min, longitude_max, latitude_max])
You can also import a shapefile or use predefined regions like countries or administrative boundaries.
Step 4: Filter Data by Time Range
Subtract the date range (1981–2022) to extract the required data:
rainfall_data = chirps.filterDate('1981-01-01', '2022-12-31')
rainfall_data = rainfall_data.select(['precipitation'])
Step 5: Export the Data
Use the Export.image.toDrive
function to download the dataset. Example code:
export_task = ee.batch.Export.image.toDrive({
image: rainfall_data,
description: 'Rainfall_1981-2022',
folder: 'GEE_Exports',
fileNamePrefix: 'rainfall',
region: region,
scale: 5000,
maxPixels: 1e9
})
export_task.start()
Monitor the task in the Code Editor’s “Tasks” panel. The data will be saved in your Google Drive.
Step 6: Post-Processing in GIS Software
Once downloaded, import the GeoTIFF or CSV files into QGIS, ArcGIS, or other GIS tools for further analysis, visualization, or modeling.
FAQ
Can I export rainfall data for multiple years separately?
Yes, use the filterDate
method with specific date ranges or iterate over years to create separate exports.
What if the data volume is too large?
Adjust the scale
parameter to reduce resolution, or use reduceRegion
to aggregate data before exporting.
Which dataset offers better accuracy?
CHIRPS combines satellite data with ground stations, while GPM provides higher spatial and temporal resolution. Choose based on your study area and requirements.
How to convert the data to CSV format?
Use Export.image.toDrive
with format: 'CSV'
in the export parameters. Ensure the export region and scale align with your needs.
Can I automate this process for multiple regions?
Yes, loop through a list of regions using map
in GEE, or use a script to handle batch exports programmatically.