I'm trying to figure out why I get different answers when calculating the total number of pixels in an image in different ways.
- Calculate a histogram on all possible values, then add together all of the categories to get the total number of pixels. This won't count NA's.
- Use the
ee.Reducer.count()
function. This also doesn't count NA's, so I would expect this to give the same answer as number 1. - Use
unmask().ee.Reducer.count()
function. This DOES count NA's, so it will be larger than number 2 if there are NA's. - print the image, look at the dimensions, and multiply the 2 dimensions to get the number of pixels. This should count NA's and I would expect it to give the same answer as number 3.
Why do these methods give different counts of the total number of pixels in an image?
Sample code: https://code.earthengine.google.com/2c4767f13001604254fa7d431af14b86