I want to make a NDSI with a ten days period from daily MOD09GA with Google Earth Engine.
The code is a adaptation from this code from Nicholas Clinton at Maximum ndvi for 3 months average in Google Earth Engine
When I use the code (the comment in the code) for renaming images after their dates, all goes well but when i try to download it, gives me error. The error is
Error: Expected a homogeneous image collection, but an image with incompatible bands was encountered: First image type: 1 bands ([2001_01_21]). Current image type: 1 bands ([2001_01_22]). Image ID: 2001_01_22 Some bands might require explicit casts.
How can I rename those NDSI's with the date name so that I can export it right?
var pol3=ee.FeatureCollection('users/georgeboldeanu20/front_WGS');
var batch = require('users/fitoprincipe/geetools:batch')
var NDSI = ee.ImageCollection('MODIS/006/MOD09GA').map(function(image) {
return image.select().addBands(image.normalizedDifference(['sur_refl_b04','sur_refl_b07'])).rename('NDSI').clip(pol3);
});
//This is the rename code
////var NDSI_name = NDSI.map( function(img){
/// var id = img.id()
///img = img.select('NDSI').rename(id);
///return img.copyProperties(img,['system:time_start','system:time_end']); });
//print(NDSI_name);
var COLlection = function(collection, start, count, interval, units) {
var sequence = ee.List.sequence(0, ee.Number(count).subtract(1));
var originalStartDate = ee.Date(start);
return ee.ImageCollection(sequence.map(function(i) {
var startDate = originalStartDate.advance(ee.Number(interval).multiply(i), units);
var endDate = originalStartDate.advance(
ee.Number(interval).multiply(ee.Number(i).add(1)), units);
return collection.filterDate(startDate, endDate)
.reduce(ee.Reducer.max());
}));
};
var days= COLlection(NDSI_name, ee.Date('2001-01-01'),10, 10, 'day');
var test = ee.Image(days.first());
print(test)
print(days)
batch.Download.ImageCollection.toDrive(luni, "Folder", {region:pol3.geometry().bounds(),crs:'EPSG:4326', scale:300});