I have an Image Collection of Images that have pixels with values of either 1000, 1000, or 1. I want to know which pixels, over the years have a value of '1000' 75% of the time, which pixels have a value of '100', 75% of the time, and which pixels have a value of '1' 75% of the time. Time being years (each image in the collection represents a single year). However, some Images do not have pixels for that year (so we have null values I assume). So, is it possible to find the 75% without knowing how many years of actual data (does GEE just ignore the null values if I were to run a calculation on the Image Collection), or... do I need to answer the following question?

How do you find out for every pixel (land area), how many years of data an Image Collection stacked together has? Some years do not have data (i.e., a pixel may have data 4/5 years in the Image Collection, another pixel may have data 3/5 years in the Image Collection). How do you do this in Google Earth Engine and then store it as a variable I can do calculations on? Or how do you count the non-null pixels and return them as an image for calculations?

1 Answer 1


In your question, you should provide some code where you tried to solve your problem.

Here's one way to approach this. See the inline comments.

// Four band image (total, 1, 100, 1000) containing counts
var counts = collection // collection contains single-band images with the class
  .map(function (image) { // Turn into band per class
    return image
  .reduce(ee.Reducer.count()) // Image with not-masked-pixel count
  .regexpRename('(.*)_count', '$1') // Drop _count from band name

// Three band image (1, 100, 1000) containing percentages of total
var percentages = counts
  .select(['1', '100', '1000'])
var maskedPercentages = percentages
  .updateMask(percentages.gte(75)) // At least 75%


  • 1
    Please use the Get Link button in the Code Editor May 28, 2021 at 11:08

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.