Here is an image collection [img1,img2,img3,img4,img5]
. I want to get List or image collection [img1, img1+img2,img1+img2+img3, img1+img2+img3+img4, img1+img2+img3+img4+img5]
.
I tried to complete the following code https://code.earthengine.google.com/20763e4a37f2341558c2b7162f02eb83. But the result image collection b
did not contain 'system:time_start'
. I don't know how to modify my algorithm. Or you have a better way to get the accumulated image collection with 'system:time_start'
.
var img1 = ee.Image(1).set('system:time_start','2001-01-01');
var img2 = ee.Image(2).set('system:time_start','2001-01-02');
var img3 = ee.Image(3).set('system:time_start','2001-01-03');
var img4 = ee.Image(4).set('system:time_start','2001-01-04');
var img5 = ee.Image(5).set('system:time_start','2001-01-05');
var image=ee.ImageCollection([img1,img2,img3,img4,img5]);
/*image = image.map(function(image) {
return image.add(1);
});*/
var list = image.toList(image.size());
var t = ee.List(image.map(function(tt){
return tt.get('system:time_start');
}))
var newList = list.slice(1);
newList = newList.iterate(function(data, list) {
data = ee.Image(data);
list = ee.List(list);
list = list.add(data.add(ee.Image(list.get(list.size().subtract(1)))));
return list;
}, ee.List([list.get(0)]));
var b = ee.ImageCollection(ee.List(newList).slice(1));
print(b)