I am trying to apply Otsu algorthm to S1 images starting from its launch to till date on my study area for waterbody mapping. I perform otsu without applying any date filter for Satellite pass so I can get more imageries. But I get the error

ImageCollection (Error) Error in map(ID=S1A_IW_GRDH_1SSV_20160525T235440_20160525T235507_011422_011607_60C4): Dictionary.get: Dictionary does not contain key: bucketMeans.

Then I tried to omit the above error by applying

.filter(ee.Filter.neq('system:id', 'COPERNICUS/S1_GRD/S1A_IW_GRDH_1SSV_20160525T235440_20160525T235507_011422_011607_60C4'))

and again I get error

ImageCollection (Error) Error in map(ID=S1A_IW_GRDH_1SSV_20160805T235445_20160805T235511_012472_0137E8_08F2): Dictionary.get: Dictionary does not contain key: bucketMeans.

and I apply another filter


But nothing works it just goes on. I came to understand the issue happens only on Descending passes. So when I put a filter to obtain Ascending pass the output progress without any errors but it won't apply the same in Descending pass.

Here is my code..


1 Answer 1


The issue is that some of the S1 images in your collection are completely masked after clipping to the geometry of your study area. To fix, filter out those images after creating your original image collection (adapted from this post):

var s1Collection = s1Collection.map(function(img){
  // unmask each image in the collection
  var unmasked = img.unmask(-99).eq(-99);
  // reduce histogram on each image and set the keys as properties (key '1' will be masked pixels)
  var rR = unmasked.reduceRegion({reducer: ee.Reducer.frequencyHistogram(),
                               geometry: img.geometry(),
                               scale: 100,
                               bestEffort: true});
  var newProperties = ee.Dictionary(rR.get('VV'));
  return img.set(newProperties)
var s1Collection = ee.ImageCollection(s1Collection).filter(ee.Filter.notNull(['0']))
print(s1Collection, 'Clean S1 Collection');

Longer explanation

Examining the image acquired on 2016-05-25 (from your example), the image footprint slightly overlaps your study area, and therefore is not excluded when you do .filterBounds(Jinjiram). But as you can see below there is no data in the Jinjiram area, so after clipping the entire image is masked: enter image description here

Because of this the histogram dictionary has null values as there is no data to summarize. See the difference below:

enter image description here

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.