Ground-truthing has never been so easy as with the GEE.
In this excercise we are going to validate the CHIRPS rainfall product with rainfall stations in the field.
Step 1: Import the Chirps image collection into the GEE.
Step 2: Import the fusion table with field measurement location.
var Rainfallstations = ee.FeatureCollection('ft:1vnNFgZt4avuVXjYm2gYsqr-25hzVefHUq3TCwUCu','geometry');
Step 3: Setup the time range for the dataseries.
// Define time range var startyear = 2000; var endyear = 2005; // Set date in ee date format var startdate = ee.Date.fromYMD(startyear,1,1); var enddate = ee.Date.fromYMD(endyear,12,31)
Step 4: Create a list with years and months.
// create list for years var years = ee.List.sequence(startyear,endyear); // make a list with months var months = ee.List.sequence(1,12);
Step 5: Filter for data and location.
// Filter chirps var Pchirps = chirps.filterDate(startdate, enddate) // Sort chronologically in descending order. .sort('system:time_start', false) .filterBounds(Rainfallstations) .select("precipitation");
Step 6: Calculate the monthly rainfall with the function below.
// calculate the P for each month var MonthlyChirps = ee.ImageCollection.fromImages( years.map(function (y) { return months.map(function(m){ var w = Pchirps.filter(ee.Filter.calendarRange(y, y, 'year')) .filter(ee.Filter.calendarRange(m, m, 'month')) .sum(); return w.set('year', y) .set('month', m) .set('system:time_start',ee.Date.fromYMD(y,m,1)) .set('date', ee.Date.fromYMD(y,m,1)) }); }).flatten());
Step 7: Add the sampling points to the map
// add items to the map Map.centerObject(Rainfallstations,8); Map.addLayer(Rainfallstations,false,"rainfall stations");
Step 8: Create a chart that samples all points for the whole image collection
// Predefine the chart titles. var title = { title: 'Precipitation', hAxis: {title: 'Time'}, vAxis: {title: 'P (mm)'}, }; // create a chart with a reducer var chart = ui.Chart.image.seriesByRegion( MonthlyChirps, Rainfallstations, ee.Reducer.mean(), 'precipitation', 5000, 'system:time_start', 'station') .setOptions(title); print(chart)
Step 9: Click the pop out icon in the right top corner.
Step 10: Download the csv file.
Step 11: Calculate the mean and compare it with the measured data.
See an example here.
Great post. Any idea how to turn the ImageCollection “MonthlyChirps” into a multiple band image for export, where each band represents the monthly aggregation?
LikeLike
Something like this? https://code.earthengine.google.com/a80e0e5dcb19a9a66d7d06ef0f616053
LikeLike
Exactly like that. Thank you.
LikeLike
Thanks for a great post. Could you please calculate monthly TRMM rainfall data? TRMM has 3 hours data so the code does not work though.
LikeLike
Do you know how to convert CHIRP-rainfall data to vector form? Specifically, I’m trying to get the average annual percipitation for each 0.5×0.5km square for one specified country. So instead of matching the data with rainfall stations as you have done here I’m looking for the data from all grid points.
LikeLike
You can apply a reducer using e.g. the country administrative boundaries to get the mean annual precipitation.
LikeLike
any idea how to get values at multiple points and export it into table with lat/lng and values in csv format
LikeLike
Do a sampleregions and add a lon lat band to your image (
ee.Image.pixelLonLat())
LikeLike
I cannot try it out. The feature collection does not exist (publicly)
LikeLike
I tried your script but it is showing me only one output in chart. any suggestions.
LikeLike