1
var l8 =ee.ImageCollection('LANDSAT/LC08/C01/T2_TOA')

var landsat2016 = l8.filterDate('2016-01-01', '2016-12-31');

var median = l8.filterDate('2016-01-01', '2016-12-31').median();

// Load or import the Hansen et al. forest change dataset.
var hansenImage = ee.Image('UMD/hansen/global_forest_change_2015');

// Select the land/water mask.
var datamask = hansenImage.select('datamask');

// Create a binary mask.
var mask = datamask.eq(1);

// Update the composite mask with the water mask.

var maskedComposite = median.mask(mask);

var maskedComposite2 = median.updateMask(mask);

So what the difference between maskedComposite and maskedComposite2?

1

In the way you apply the mask and updateMask, there is no difference. I would rather use updateMask, as this is written about the mask function:

Note: the version that sets a mask will be deprecated. To set a mask from an image on previously unmasked pixels, use Image.updateMask. To unmask previously masked pixels, use Image.unmask.

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.