1

I have written a small function that first takes an image, calculates mean for each of its bands and then converts the dictionary of the mean value to an image with each mean value acting as a new band to the image.

When I applied this function to one image, it worked. However, when I mapped this function to an image collection, it shows an error.

enter image description here

I didn't quite understand what the error mean. Also, I think the function is actually being executed in the image collection as well because when I print the results, I don't get any error. The error occurs when I try to add the result as a layer.

The link to the code is below: https://code.earthengine.google.com/3b0279b87c668347dccae455b4e42974

0

The error is telling you what's going on: band B10 might require an explicit cast but don't cast just that band because it will throw the same error for the next, and so on. Cast all bands.

var meanref = function (image){
  var meanDictionary = (image.select('B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11').reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: image.geometry(),
  scale: 30,
  maxPixels: 1e9
}));
  // Cast all bands of the result to be of Integer type
  return  meanDictionary.toImage().updateMask(image.select('B11')).toInt();
};

https://code.earthengine.google.com/c3f744e390a29296108ba16b70e30cb3

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.