I calculated an image collection with the property "date". Now I want to add the property "date" as a new band but I got the error "Actual value for parameter 'id' must be a constant". Instead of .getString I also tried .get and .getNumber.
// Add band:
var add_band = function(img) {
var bandDate = img.getString('Date');
return img.addBands(bandDate);
}
var new_mask = s1_mask.map(add_band);
print('ImageCollection new mask', new_mask)
And is it possible to transform the new band in a date format such as YYYY_MM_DD?
---EDIT--- -> solution
var addDate = function(image){
var dateNum = ee.Image(image).date().millis()
var doyBand = ee.Image.constant(dateNum).rename('date').toFloat()
doyBand = doyBand.updateMask(image.select('VV').mask())
return image.addBands(doyBand);
};
var withDate = s1.map(addDate);
print(withDate);