0

I have 5 years of Landsat data that I stacked into an Image Collection. If I calculated the mean of that Image Collection, and a pixel does not have data for one or more of the years, is that pixel ignored in the calculation?

Additionally, I have a dataset of crop yields. If I check if the crop yield is less than the mean of the Image Collection and assign it a number, but a pixel does not have data for that year, is that pixel just not included in the calculation or is it represented by a 0 and therefore would be counted as less than?

//Create Image Stack
var ColG = ee.ImageCollection.fromImages([ee.Image(GY13_adj),
      ee.Image(GY14_adj),ee.Image(GY15_adj),ee.Image(GY16_adj),
      ee.Image(GY17_adj),ee.Image(GY18_adj),ee.Image(GY19_adj),ee.Image(GY20_adj)]);

var ColS = ee.ImageCollection.fromImages([ee.Image(SY13_adj),
      ee.Image(SY14_adj),ee.Image(SY15_adj),ee.Image(SY16_adj),
      ee.Image(SY17_adj),ee.Image(SY18_adj),ee.Image(SY19_adj),ee.Image(SY20_adj)]);


//#Mean/median of all years for each pixel
var mG = ColG.mean();
var mS = ColS.mean();
//mG<-ColG.reduce(ee.Reducer.mean());
//mS<-ColG.reduce(ee.Reducer.mean());

//#Grain
var y13 = GY13_adj;
var reclass13 = ee.Image(1).where(y13.gte(mG),1000).where(y13.lt(mG),100);
0

If I calculated the mean of that Image Collection, and a pixel does not have data for one or more of the years, is that pixel ignored in the calculation?

Earth Engine will compute the mean of the values from all of the images that have pixels (are unmasked) at that location. If there are no such pixels (the mean would have no input values), then the output will be masked.

Additionally, I have a dataset of crop yields. If I check if the crop yield is less than the mean of the Image Collection and assign it a number, but a pixel does not have data for that year, is that pixel just not included in the calculation or is it represented by a 0 and therefore would be counted as less than?

You used the where operation. The documentation for where says:

If at a given pixel, either test or value is masked, the input value is used. If the input is masked, nothing is done.

The “test” image is y13, and the input is a constant ee.Image(1) which is fully unmasked (has data everywhere), so you'll get a 1 value where y13 is masked.

This is somewhat unusual; most arithmetic and other pixel-by-pixel image operations will mask an image wherever either input is masked (i.e. the result is valid only when both inputs are valid).

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.