I have imagecollection from sentinel which I would like to run few processes on it by using loop. I know what are the steps of the loop that I want and I have written draft that ia full of errores and I would like to get help in writing it correct.
The needd steps are:
- apply the next function on each image:
//Apply Frost filter for speckle correction
function Frost(image, frostDamp, ksize)
// Frost is really a simplified version of GammaMap
// Make sure to pass the frost damp factor (frostDamp) as a NEGATIVE number
{
// ~~(ksize/2) does integer division in JavaScript
var distance_kernel = ee.Kernel.euclidean(~~(ksize/2));
// Square kernel, ksize should be odd (typically 3, 5 or 7)
var weights = ee.List.repeat(ee.List.repeat(1,ksize),ksize);
var kernel = ee.Kernel.fixed(ksize, ksize, weights, ~~(ksize/2), ~~(ksize/2), false);
// Get mean and variance
var mean = image.reduceNeighborhood(ee.Reducer.mean(), kernel);
var variance = image.reduceNeighborhood(ee.Reducer.variance(), kernel);
var B = variance.multiply(frostDamp).divide(mean.multiply(mean));
var W = B.exp().reduceNeighborhood(ee.Reducer.mean(), distance_kernel);
return image.multiply(W).reduceNeighborhood(ee.Reducer.sum(), kernel).divide(W.reduceNeighborhood(ee.Reducer.sum(), kernel));
}
- calculate new imagecollection , for each image ,each pixel will be calculted as folloing:
//here I would like to run calculation for each image in my imagecollection:
var calc=i.expression(
'3.75-(-0.521*VH)+(0.34*VV)+(3.12*NRPB)', {
'VH': i.select('VH_sum'),
'VV': i.select('VV_sum'),
'NRPB': VH.subtract(VV).divide(VH.add(VV)).rename('NRBP')
});
all of it will create new imagecollection.
I have tried to apply the first function using this:
var FrostDB=clippedSAR.map(function(im){
return im.Frost(geometry);
});
but got this error:
im.Frost is not a function
My end goal is to create one loop that can run all the mentioned processes on an imagecollection, and also to get deeper understanding of loops in GEE