0

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

Map.centerObject(geometry);

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

var modis = MOD09
.filterDate('2015','2020')
.filterBounds(geometry)
.map(modisData)


print(modis)

1 Answer 1

0

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.

https://code.earthengine.google.com/f383b8171ad11bc8be6d7b11b040bd0d

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.