Google Earth Engine Tutorial: Generate Annual Precipitation Raster
Credit: Youtube Channel “Terra Spatial, Tutorial on creating annual precipitation raster maps using CHIRPS rainfall data.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine Tutorial: Generate Annual Precipitation Raster
Google Earth Engine (GEE) offers powerful tools to process satellite and climate data. This tutorial demonstrates how to generate an annual precipitation raster using GEE. Follow these steps to extract and visualize annual precipitation data from a global dataset.
Step 1: Load the Precipitation Dataset
Start by selecting a global precipitation dataset. A common choice is the Climate Hazards Group Infrared Precipitation with Stations (CHIRPS), which provides high-resolution rainfall data.
var precipitation = ee.ImageCollection("UCSB-CCAP/CHIRPS/DAILY");
Step 2: Filter by Time and Region
Filter the dataset to your region of interest and specify the year you want to analyze.
var region = ee.Geometry.Rectangle([xmin, ymin, xmax, ymax]); // Replace with your coordinates
var year = 2020;
var filtered = precipitation.filterDate(ee.Date(year), ee.Date(year).advance(1, 'year'))
.filterBounds(region);
Step 3: Compute Annual Precipitation
Calculate the annual total by summing daily precipitation values and converting them to millimeters.
var annualPrecipitation = filtered.select('precipitation')
.sum()
.multiply(0.1) // Convert to millimeters
.rename('annual_precipitation');
Step 4: Visualize the Raster
Display the annual precipitation raster on the map and adjust visualization parameters.
Map.setCenter(x, y, zoom); // Replace with your coordinates and zoom level
Map.addLayer(annualPrecipitation, {min: 0, max: 1000, palette: ['white', 'blue']}, 'Annual Precipitation');
Step 5: Export the Raster
Export the annual precipitation raster to Google Drive for further analysis.
Export.image.toDrive({
image: annualPrecipitation,
description: 'annual_precipitation',
folder: 'GEE_Exports',
fileNamePrefix: 'annual_precipitation',
region: region,
scale: 5000, // Resolution in meters
crs: 'EPSG:4326', // WGS84 coordinate system
fileFormat: 'GeoTIFF'
});
FAQ
How do I access the CHIRPS dataset in Google Earth Engine?
The CHIRPS dataset is available in the GEE Code Editor under the “UCSB-CCAP/CHIRPS/DAILY” catalog entry. It provides precipitation data at 0.05Β° resolution.
Why is the scale set to 5000 meters in the export?
The scale determines the spatial resolution. 5000 meters is a common choice for global datasets, but adjust it based on your study area and data requirements.
Can I use other precipitation datasets with GEE?
Yes. Popular alternatives include the Global Precipitation Measurement (GPM) dataset or ERA5-Land. Adjust the dataset name and parameters accordingly.
What if the image appears blank or unresponsive?
Ensure you have a stable internet connection and a valid GEE account. Check the date range and region filter in your code for accuracy.
How do I calculate the mean instead of the total?
Replace .sum()
with .mean()
in the code. This method computes the average daily value for the year.
What is the difference between ‘sum’ and ‘mean’ for precipitation?
sum()
adds all daily values for the year, showing total rainfall. mean()
calculates the average daily value iteratively, useful for comparing seasonal trends.