I need to create a Google Earth Engine (JavaScript API) function to mask the pixels corresponding to no_data
, satured_or_defective
, dark_area_pixels
, cloud_shadows
, unclassified
, cloud_medium_probability
, cloud_high_probability
and thin_cirrus
in Sentinel-2 L2A images according to the SCL product.
My intuition tells me that the function would start like this:
function s2_clear_sky(image){
// 1.Locate SCL product
var scl = image.select('SCL');
// 2.SCL classification
var no_data = scl.eq(0);
var satured_or_defective = scl.eq(1);
var dark_area_pixels = scl.eq(2);
var cloud_shadows = scl.eq(3);
var vegetation = scl.eq(4);
var not_vegetated = scl.eq(5);
var water = scl.eq(6);
var unclassified = scl.eq(7),
var cloud_medium_probability = scl.eq(8);
var cloud_high_probability = scl.eq(9);
var thin_cirrus = scl.eq(10);
var snow = scl.eq(11);
// 3.Apply mask to the image
¿¿¿???
return image.updateMask(¿¿¿???)
}
Finally this function would be applied to the entire ImageCollection
using the .map()
function:
var s2_masked = s2_collection.map(s2_clear_sky)
How can I implement this function?