I need to use max reducer keeping as additional band information from which day of the year the data comes from.
Got a function adding a day of the year band to the image, that I can map a collection with:
var addDate = function(image){
var doy = image.date().getRelative('day', 'year');
var doyBand = ee.Image.constant(doy).uint16().rename('doy')
doyBand = doyBand.updateMask(image.select('B8').mask())
return image.addBands(doyBand);
};
But how do I now having some collection, for example:
var collection = ee.ImageCollection('LANDSAT/LT05/C01/T1')
.filterDate('2008-01-01', '2008-12-31')
.filter(ee.Filter.eq('WRS_PATH', 44))
.filter(ee.Filter.eq('WRS_ROW', 34));
reduce it with max()
reducer, but so it would add additional bands with information from which day of the year every pixel with maximum value was taken?
To be more specific: Lets say that I need for example only max of B1
. As an output I would like to have 2 bands - 1st: max()
of B1
s from the collection, second - DOY
for every pixel (from which day the max value image of that pixel in the collection was).