0

Is there way to reduce an image collection by numbers how many images matching conditions?

For example, I want to create a new image to visualize how many days meet some conditions in a period.

ref image

leccmo
  • 329
  • 4
  • 16

1 Answers1

1

When you want to convert an image collection to an image by combining all the pixels in some way for each spatial location, the solution is ImageCollection.reduce. In this case, we can use the ee.Reducer.count reducer to count the number of pixels meeting the condition.

JavaScript example:

var daysMeetingConditionImage = imageCollectionOfDayImages
  .map(function (image) {
    // Apply the condition, whatever it is, as a mask.
    // Masked-off pixels will not be counted.
    return image.updateMask(
       image.select('B2').gt(7)  // Change this to whatever your per-pixel condition is
    );
  })
  .reduce(ee.Reducer.count());
Kevin Reid
  • 37,492
  • 13
  • 80
  • 108