Point sampling with Google Earth Engine

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)

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'))
    return w.set('year', y)
             .set('month', m)
             .set('date', ee.Date.fromYMD(y,m,1))

Step 7: Add the sampling points to the map

// add items to the map
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')


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.


  1. Great post. Any idea how to turn the ImageCollection “MonthlyChirps” into a multiple band image for export, where each band represents the monthly aggregation?

      1. 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.

  2. 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.

  3. any idea how to get values at multiple points and export it into table with lat/lng and values in csv format

Leave a Reply