I have a long imagecollection of Landsat-5 images from 1984 to 2011. This imagecollection was cropped in a smaller ROI, bit flags and scaling factors applied and for each image two new bands were calculated, NDVI and NDWI.
Next, I'm trying to calculate a new image collection which will consist of the max NDVI and median NDWI for each year of the initial image collection.
Unfortunately I get the error:
ImageCollection (Error) User memory limit exceeded
I also tried to minimize the memory footprint by converting the max and median images toByte but the error still occurs.
For shorter timeseries (for example 1984-2000) the imagecollection is generated without problem.
This is the function that I'm using:
//Function: Calculate max NDVI and median NDWI for each year
var annual_max_NDVI_median_NDVI = ee.ImageCollection(ee.List.sequence(1984, 2011).map(function (year){
var date_start = ee.Date.fromYMD(year, 1, 1);
var date_end = date_start.advance(1, "year");
var image1 = NDVI5
.select('ndviNorm')
.filterDate(date_start, date_end)
.reduce(ee.Reducer.max(),16).rename('NDVI')
.set({year: year, 'system:time_start':date_start.millis()})
.set({year: year, 'system:time_end':date_end.millis()});
var image2 = NDVI5
.select('NDWI')
.filterDate(date_start, date_end)
.reduce(ee.Reducer.median(),16).rename('NDWI')
.set({year: year, 'system:time_start':date_start.millis()})
.set({year: year, 'system:time_end':date_end.millis()});
var image = image1.addBands(image2)
return(image);
}));
.filter(ee.Filter.bounds(ROI))