I am currently trying to calculate the rain use efficiency index for the years 2000-2015 with a Landsat dataset (NDVI) and a CHIRPS (precipitation) dataset.
I already have two image collections with the property year
and each has one band. One with NDVI nd
the other has precipitation
. The Landsat ImageCollection
is already prepared and was also smoothed.
var years = ee.List.sequence(2000,2015);
var byYear = ee.ImageCollection.fromImages(
years.map(function (y) {
var start = ee.Date.fromYMD(y, 07, 1);
var stop = start.advance(1, 'year');
var sumVeg = smoothed.filterDate(start, stop).select('nd').median();
return sumVeg.set('year', y);
}));
var dataset = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filter(ee.Filter.date('2000-01-01', '2015-12-31'));
var precipitation = dataset.select('precipitation');
var years = ee.List.sequence(2000,2015);
var yearCHIRPS = ee.ImageCollection.fromImages(
years.map(function (y) {
var start = ee.Date.fromYMD(y, 07, 1);
var stop = start.advance(1, 'year');
var sumprec = precipitation.filterDate(start, stop).select('precipitation').sum();
return sumprec.set('year', y);
}));
mergedCollection = byYear.merge(yearCHIRPS);
The result is an image collection with 32 images, but I rather want to have 16 images with each two band (NDVI and precipitation) and then to calculate the RUE by dividing the NDVI through the annual precipitation with the map function.
The code is here https://code.earthengine.google.com/382aac21f969e829fd609903184d7395