I have a image collection which holds multiple images of the same area. I can apply mask individually to those images but how do I apply a mask to all the images in the collection. Say the mask i have to apply is to filter out all the pixels with value more than a given value. Since i have multiple images for the same location, I want to 'and' the logic so that i get a single image with pixels displayed which satisfy the condition for all the images. Here is some code i wrote which works for fine when i have single image:
Map.setOptions('SATELLITE')
var image = ee.ImageCollection("imagesForIrvineCalifornia");
var min = image.aggregate_min('min');
var max = image.aggregate_max('max');
var VIS_OPTIONS = {
'b1': {
description: 'b1' +
'b1 descripion',
visParams1: {min:min.getInfo(), max:max.getInfo(), palette: ['DCF5E9', 'BDDEC9', '9DC7AA', '82B38E','689E75', '4E8A5B', '387847'], bands: ['b1']}
}
};
var maskingFunc = function(val){
return function(i){
var band = i.select('b1');
var mask = band.lte(val);
return i.updateMask(mask);
}
}
var maskedImage = image;
var cutoffVal=3000 ;
maskedImage = image.map(maskingFunc(cutoffVal));
Map.addLayer(maskedImage.select('b1'), VIS_OPTIONS['b1'].visParams1, '(b1)', true);
Map.centerObject(Map.layers().get(0).get('eeObject'));