On Lab 6: Time series analysis from https://developers.google.com/earth-engine/edu, there is maskClouds
:
var maskClouds = function(image) {
var quality = image.select('BQA');
var cloud01 = quality.eq(61440);
var cloud02 = quality.eq(53248);
var cloud03 = quality.eq(28672);
var mask = cloud01.or(cloud02).or(cloud03).not();
return image.updateMask(mask);
};
While in Lab 1: Intro to Remote Sensing and EE, clouds are filtered with a different approach:
// Sort the collection by a metadata property.
.sort('CLOUD_COVER')
// Get the first image out of this collection.
.first());
When should I use each of these approaches?