In the below code time band doesn't create for merged collection. I don't know why but it returns metadata error:

enter image description here

code link: https://code.earthengine.google.com/3827c156af430c2485aedf28f9273206


var temporalCollection = function(collection, start, count, interval, units){
  var sequences = ee.List.sequence(0,ee.Number(count).subtract(1.0));
  var originDate = ee.Date(start);
  return ee.ImageCollection(sequences.map(function(i){
    var startDate = originDate.advance(ee.Number(interval).multiply(i),units);
    var endDate = originDate.advance(ee.Number(interval).multiply(ee.Number(i).add(1)),units);
    return collection.filterDate(startDate, endDate).mean().clip(geometry)
    .set('system:time_end', endDate.millis());

var AOD = function(img){
  var bands = img.select('Optical_Depth_055').multiply(0.001).clip(geometry);
  return bands.copyProperties(img,['system:time_start','system:time_end']);

var TIME = function(img){
  var time = ee.Image(img.metadata('system:time_start'));
  return img.addBands(time).copyProperties(img,['system:time_start','system:time_end']);

var modisAOD1 = ee.ImageCollection("MODIS/006/MCD19A2_GRANULES")

var modisAOD16DAYS1 = temporalCollection(modisAOD1, '2001-01-01', 228, 16, 'days');

print('MODIS AOD 16DAYS 2001-2010:',modisAOD16DAYS1);

var modisAOD2 = ee.ImageCollection("MODIS/006/MCD19A2_GRANULES")

var modisAOD16DAYS2 = temporalCollection(modisAOD2, '2011-01-01', 228, 16, 'days');

print('MODIS AOD 16DAYS 2011-2020:',modisAOD16DAYS2);

var modisAOD16DAYS = modisAOD16DAYS1.merge(modisAOD16DAYS2);

print('MODIS AOD 16 DAYS 2001-2020:',modisAOD16DAYS);

var modisAodChange = modisAOD16DAYS.map(TIME);


1 Answer 1


Oh, one of those classic errors where you really don't know what is going wrong. The solution is really simple, there's a typo in your function temporalCollection().

return collection.filterDate(startDate, endDate).mean().clip(geometry)
.set('system:time_end', endDate.millis());

In line 2 it should by system instead of systam. Something like this happened to all of us at one point, so I can definitely feel your pain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.