I need extract date of each image and set to the id in each date by the below code. Although all elements in modis collection included 'system:time_start' property, code returns error. Does anyone has any idea?

enter image description here

Code link: https://code.earthengine.google.com/a197f55e46e62099a53a9d47dc171f7e


var modisData = function(img){
  var bands = img.select('su.*').multiply(0.0001);
  var date = ee.String(bands.date().format('YYYY-MM-dd'));
  return bands
  .set('system:id', date)

var modis = MOD09


1 Answer 1


This seems to work with explicit casts:

 var date = ee.Algorithms.String(ee.Date(img.get('system:time_start')).format('YYYY-MM-dd'))

Not sure why your .date() approach is failing on MODIS though.


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.