I am having two image collections, sc, data(Sentinel 1 data).
I need to do an iterative type of computation where I need to use previous output for the next iteration and also multiple images using two different index for computation.
This is the algorithm that I need to perform.
SC and the backscatter values are present in the image collection. A change detection index (SI) needs to be calculated for each location i and time step t.
I tried to perform using the following code and I am getting this error.
var i = data.size();
var e = i.subtract(2);
var co = ee.List.sequence(0, e);
print("list", co);
//Calculating snow index
var si_1 = ee.Image(0).expression(
'(VH/VV)*SC', {
'VV': ee.Image(data.toList(data.size()).get(0)).select('VV_1'),
'VH': ee.Image(data.toList(data.size()).get(0)).select('VH_1'),
'SC': ee.Image(sc.toList(sc.size()).get(0)).select(0)
}).copyProperties(data);
var si_2 = ee.Image(0).expression(
'(SI + (VH/VV) - (VHp/VVp))*SC', {
'VV': ee.Image(data.toList(data.size()).get(1)).select('VV_1'),
'VH': ee.Image(data.toList(data.size()).get(1)).select('VH_1'),
'VVp': ee.Image(data.toList(data.size()).get(0)).select('VV_1'),
'VHp': ee.Image(data.toList(data.size()).get(0)).select('VH_1'),
'SI': ee.Image(si_1),
'SC': ee.Image(sc.toList(sc.size()).get(1)).select(0)
}).copyProperties(data);
var si = ee.ImageCollection.fromImages([si_1, si_2]);
print('SI_1', si);
// Funtion for iteraton over the image collection to compute Snow Index
var Snow_index = function(is, newlist) {
is = ee.Number(is);
var is_ = is.add(1);
newlist = ee.List(newlist);
var si_ = ee.List(ee.Image(0).expression(
'(SI + (VH/VV) - (VHp/VVp))*SC', {
'VV': ee.Image(data.toList(data.size()).get(is_)).select('VV_1'),
'VH': ee.Image(data.toList(data.size()).get(is_)).select('VH_1'),
'VVp': ee.Image(data.toList(data.size()).get(is)).select('VV_1'),
'VHp': ee.Image(data.toList(data.size()).get(is)).select('VH_1'),
'SI': ee.Image(si.toList(si.size()).get(is)).select(0),
'SC': ee.Image(sc.toList(sc.size()).get(is_)).select(0)
}));
// Add the SI to a list
return ee.List(ee.List(newlist).add(si_))
}
Error: List (Error) List.add, argument 'list': Invalid type. Expected type: List. Actual type: ImageCollection.
It would be really helpful if someone could help me sort it out.
Link to the code: https://code.earthengine.google.com/8b423c3909b152beb985a806c169b432