Water consumption by land-use class

How much water is consumed by all these forests?

Step 1: Import the chirps dataset

Step 2:  Set the time and date variable.

// variables for start and end year
var startyear = 2006;
var endyear = 2006;

// create a list with months
var months = ee.List.sequence(1,12);

// define start and end date
var startdate = ee.Date.fromYMD(startyear,1,1);
var enddate = ee.Date.fromYMD(endyear,12,1);

// create list for years
var years = ee.List.sequence(startyear,endyear);

Step 3: Import the ET dataseries

// import actual ET data
var aET = ee.ImageCollection("users/atepoortinga/etdata");

Step 4: Import the landuse map you create in this exercise.

// landuse map
var luse = ee.FeatureCollection('ft:1Hgt_gN4R7opnaFxamqJsJnkic_WWunxgbBtHsT5J','geometry');

Step 5: Filter on date and location.

// select P for time range
var P = chirps.filterDate(startdate, enddate)
  // Sort chronologically in descending order.
  .sort('system:time_start', false)

// select aET for time range
var aET = aET.filterDate(startdate, enddate)
  // Sort chronologically in descending order.
  .sort('system:time_start', false)

Step 6: Calculate the monthly Precipitation

// calculate the P for each month
var allP =  ee.ImageCollection.fromImages(
  years.map(function (y) {
  return months.map(function(m){
  var w = P.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: Create a chart with the Monthly rainfall for each landuse class.

// Predefine the chart titles.
var title = {
  title: 'Rainfall',
  hAxis: {title: 'Time'},
  vAxis: {title: 'P (mm)'},

// setup the chart for P
var chart = ui.Chart.image.seriesByRegion(allP, luse, ee.Reducer.mean(), 'precipitation', 2500, 'system:time_start', '??')


Step 9: Do the same for ET.

Step 10: Do the same for incremental ET you created in this exercise.

One comment

  1. How did you filter the data by land use category? I ran the code and it only extracted monthly precipitation for the entire region.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s