1

I have sentinel-1 dataset and I want to map Frost filter function on each image in the dataset. The problem is that when I try to do this. using map, I get the error:

Required argument (count) missing to function: List.repeat(value, count)

Returns a new list containing value repeated count times.

Args:

value (Object): Undocumented. count (Integer): Undocumented.

I have tried to insert those values, but it also didn't work and I keep get the same error.

this is my code:


var Sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
        .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
        .filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))
        .filter(ee.Filter.eq('instrumentMode', 'IW'))
        .select('VH','VV','angle')
        .filterDate('2019-10-01', '2020-01-01')
        .filterBounds(geometry);

var clippedSAR= Sentinel1.map(function(im){ 
  return im.clip(geometry);
}); 


//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));
}

//this is when I tried to insert values.
var frost_result=clippedSAR.map(Frost(-1,5));

//originally did that:
var frost_result=clippedSAR.map(Frost);


My end goal: To map this function on all the images in the image collection and then to create time series.

Edit:

I thought maybe the error is because I have 2 bands, so I seperated them but still get the same error:

var vv=clippedSAR.select('VV');
var vh=clippedSAR.select('VH');

var frost_result=vv.map(Frost(-1,5));

//also tried:
var frost_result=vv.map(Frost);

4

Your issue is, that functions which you pass to .map() only take 1 argument and nothing else. So your other parameters of frostDamp and ksize do not get passed to the function and thus do nothing. That's why you get the error, because ksize is not assigned to anything.

You can fix this by wrapping the map function into your Frost function. Like this:

//Apply Frost filter for speckle correction
function Frost(collection, frostDamp, ksize)
// Frost is really a simplified version of GammaMap
// Make sure to pass the frost damp factor (frostDamp) as a NEGATIVE number
{
  return collection.map(function(image){
    // ~~(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));
  })
}

//this is when I tried to insert values.
var frost_result = Frost(clippedSAR, -1, 5)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.