I am trying to iterate through an image collection and add a property to each image that is taken from a list. For example I want image 1 in the collection to have the property list item 1.
I first get the collection like so
var collection = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(AOI)
.filterDate(startDate,endDate)
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filter(ee.Filter.eq('resolution_meters', 10)) // orbital path needs to change
.select('VV');
then I create a list and convert to a date
var index = collection.aggregate_array('system:index');
function extract(title){
var cal = ee.String(title).slice(17, 25);
var time = ee.String(title).slice(26, 32);
var imgdate = ee.Date.parse('yyyyMMddHHmmss',cal.cat(time));
return imgdate;
}
var dates = index.map(extract);
then I wanted to create a new property called date and add the corresponding list item to the image.
var i = 0;
function joindate (img){
img.set({'Date': dates.get(i)});
i = i+1;
return img;
}
collection = collection.map(joindate);
I get no errors but when I look at the image properties, no new properties are made.
Here is a link to my code, but there are a lot more processes going on https://code.earthengine.google.com/381595639a2961eb100cdfde05625e2f