I received this collection of ordered multiband images and would like to convert them to a single collection, adding a timestamp (system:time_end and system:time_start):
https://code.earthengine.google.com/fdc4aa75742a5b68f3d67813e1086da9
I received this collection of ordered multiband images and would like to convert them to a single collection, adding a timestamp (system:time_end and system:time_start):
https://code.earthengine.google.com/fdc4aa75742a5b68f3d67813e1086da9
I'm sure there is a more elegant way to transfer your bands to an image collection but this is my take on it. Be aware that transferring the Day of Year to an date object like you requested didn't work yet. Instead I added seperate properties for day, month and year to the separate images.
var bandToCollection = function(collection){
// get band names
var bands = collection.bandNames()
var dayCounter = ee.List.sequence(1, bands.size())
// build new collection with 1 image per band
var newCollection = dayCounter.map(function(b){
var img =
ee.Image(collection.select(ee.String(bands.get(ee.Number(b).subtract(1)))))
var id = img.propertyNames()
var prop = ee.String(img.get('system:id')) // get ID
var year = ee.Number(ee.String(prop.split('/').get(2)).split('-').get(4))
// extract the year value
var dateTest = ee.Date.parse('D',ee.Number.parse(ee.Number(b).format('%03d')))
// also yse the day counter to set the Day Of Year
// something goes wrong with converting the number to a date, so left this out
// at the moment
var finalDate = ee.Date.fromYMD(ee.Number.parse(year), dateTest.get('month'),
dateTest.get('day')).millis()
// return img.set('system:time_end', year)
return(img.set('year', year).set('doy', b).set('month',
dateTest.get('month')).set('day', dateTest.get('day')))
})
return newCollection
}
full working example: https://code.earthengine.google.com/57c22e93c861c9a02c2eb62d620ed897