Google Earth Engine Tutorial: Extract Rainfall at Sample Points
Credit: Youtube Channel “Terra Spatial, Learn how to extract rainfall data at random sample points from CHIRPS dataset for spatial analysis.”
You can see all the tutorials from here: Techgeo Academy.
Introduction to Rainfall Extraction Using Google Earth Engine
Google Earth Engine (GEE) is a powerful platform for analyzing geospatial data, particularly useful for environmental and climate studies. One common task is extracting rainfall data at specific sample points. This tutorial explains how to perform this using GEE’s API and JavaScript. Rainfall data is often available through datasets like the Climate Hazards Group InfraRed Precipitation with Stations (CHIRPS) or the ERA5 reanalysis dataset, which provide global precipitation information at a fine resolution.
Steps to Extract Rainfall at Sample Points
Access the rainfall dataset. For example, load the CHIRPS dataset with:
var rainfall = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY');
Create a FeatureCollection of sample points. If using a shapefile, use:
var samplePoints = ee.FeatureCollection('users/yourusername/your_points');
Filter the image collection to the desired date range. For instance:
var filteredRainfall = rainfall.filterDate('2023-01-01', '2023-12-31');
Use the
reduceRegion
method to calculate rainfall values at the sample points. Example:
var result = filteredRainfall.select('precipitation').mean().reduceRegions({
collection: samplePoints,
reducer: ee.Reducer.mean(),
scale: 25000
});
Export the results to a CSV file or visualize them on the map:
Export.table.toDrive({
collection: result,
description: 'rainfall_extraction',
fileNamePrefix: 'rainfall_data',
fileFormat: 'CSV'
});
Sample Code Integration
Here is a full script to extract monthly rainfall data:
var dataset = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterDate('2023-01-01', '2023-01-31')
.select('precipitation');
var points = ee.FeatureCollection('users/yourusername/your_points');
var monthlyRainfall = dataset.mean().reduceRegions({
collection: points,
reducer: ee.Reducer.mean(),
scale: 25000
});
print(monthlyRainfall);
FAQ Section
- How do I handle multiple time periods?
Use the filterDate method to specify different date ranges or process data in batches using loops or time-based joins.
- Can I use a different rainfall dataset?
Yes. GEE hosts several global rainfall datasets, such as TRMM, GPM, or ERA5. Replace the dataset name in the script with the desired source.
- How does GEE calculate rainfall values?
By default, GEE uses the mean reducer, but you can opt for other statisticians like sum or median depending on your analysis goals.
- What if the sample points are not in the same projection as the dataset?
Ensure the points are reprojected to match the dataset’s projection using the
reproject
method or adjust the scale parameter in reduceRegion. - How can I visualize the extracted data?
Use
Map.addLayer()
to preview the data or export it to a CSV file and open in a spreadsheet application.