I have an image collection which has undergone certain processes such as resampling and rescaling. Now I am trying to mosaic the images based on the date of acquisition.
I tried the code from Mosaicking Image Collection by Date (day) in Google Earth Engine
var start = ee.Date(start_date);
var finish = ee.Date(end_date);
// Difference in days between start and finish
var diff = finish.difference(start, 'day');
// Make a list of all dates
var range = ee.List.sequence(0, diff.subtract(1)).map(function(day)
{return start.advance(day,'day')});
// Funtion for iteraton over the range of dates
var day_mosaics = function(date, newlist) {
// Cast
date = ee.Date(date);
newlist = ee.List(newlist);
// Filter collection between date and the next day
var filtered = Res_collection.filterDate(date, date.advance(1,'day'));
// Make the mosaic
var image = ee.Image(filtered.mosaic()).set('system:time_start',filtered.get('system:time_start'));
// Add the mosaic to a list only if the collection has images
return ee.List(ee.Algorithms.If(filtered.size(), newlist.add(image), newlist));
};
// Iterate over the range to make a new list, and then cast the list to an imagecollection
var newcol = ee.ImageCollection(ee.List(range.iterate(day_mosaics, ee.List([]))));
print('Mosaic', newcol);
But I am getting 0 images in my output. I think I am losing the system:time_start property somewhere before the mosaic step (during resampling and rescaling) because the code runs fine before doing the processes.
Can someone identify the mistake that I am making?
My full code: https://code.earthengine.google.com/8f85b69b3009168cf76ae5e23471affc