I have a sentinel -1 image collection and I have a function that suppose to use focal median in order to apply speckle correction. Each image has 2 bands: VV and VH and the function I have suppose to run this filter on each one and then to add those two bands to the image.

The problem: The added bands don't get the names I chose, as you can see in the following 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'))

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


var filterSpeckles = function(img) {
  var VH = img.select('VH') ;//select the VH polarization band
  var VV=img.select('VV');
  var VH_smoothed = VH.focal_median(5,'circle','meters').clip(geometry).rename('VH_Filtered'); //Apply a focal median filter
  var VV_smoothed = VV.focal_median(5,'circle','meters').clip(geometry).rename('VH_Filtered'); //Apply a focal median filter
  return img.addBands(VH_smoothed).addBands(VV_smoothed);

var Clipped_Speckles = clippedSAR.map(filterSpeckles);

When I print this I get those bands:

enter image description here

Even though in the code I gave different names to the bands:

  return img.addBands(VH_smoothed).addBands(VV_smoothed);

why is this happening? how can I be sure it adds the correct bands+ give them the right names?

  • Hi Reut. It looks like @Daniel 's answer satisfies your question. Can you please remember to accept answers to remove questions from the list of unanswered questions. It is also a nice way to acknowledge those that have spent time to answer your questions. Feb 6, 2020 at 19:26
  • yes ofcurse, I just still haven't gotten to this , i'm greatfuk to Daniel and he helps me a lot
    – ReutKeller
    Feb 7, 2020 at 13:41

2 Answers 2


You're adding two bands with the same name, VH_Filtered, with the overwrite argument set to false. It behaves like the documentation states - it renames the band with a numerical suffix.

addBands(srcImg, names, overwrite)


overwrite (Boolean, default: false):

If true, bands from srcImg will override bands with the same names in dstImg. Otherwise the new band will be renamed with a numerical suffix ('foo' to 'foo_1' unless 'foo_1' exists, then 'foo_2' unless it exists, etc).


You probably copy-pasted the variable declaration without changing rename() part


var VV_smoothed = V.focal_median(5,'circle','meters').clip(geometry).rename('VH_Filtered');

Should be

var VV_smoothed = V.focal_median(5,'circle','meters').clip(geometry).rename('VV_Filtered');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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