1

How do you calculate the average value for each pixel across multiple images in GEE?

I thought about adding all the images and then dividing by the number of images but there may be pixels with no data in some of the images.

var GYav1 = GY13.add(GY14);
var GYav2 = GYav1.add(GY15);
var GYav3 = GYav2.add(GY16);
var GYav4 = GYav3.add(GY17);
var GYav5 = GYav4.add(GY18);
var GYav6 = GYav5.add(GY19);
var GYav7 = GYav6.add(GY20);

var GYav = GYav7.divide(8); 
2
3

In Earth Engine, reducers automatically handle missing (masked) data, so the mean reducer will take the mean of all the pixels actually present.

var GYav = ee.ImageCollection([
  GY13,
  GY14,
  GY15,
  GY16,
  GY17,
  GY18,
  GY19,
  GY20,
]).mean();

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.