7

Working with GEE I noticed that there are different methods for masking cloud pixels in Sentinel-2 images. I would like to clear up some doubts about the different methods. Here are two of the functions I found for cloud masking:

function maskS2clouds(image) {
  var qa = image.select('QA60');
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
             qa.bitwiseAnd(cirrusBitMask).eq(0));
  return image.updateMask(mask).divide(10000)
      .select("B.*")
      .copyProperties(image, ["system:time_start"]);
};

and

function s2ClearSky(image) {
      var scl = image.select('SCL');
      var clear_sky_pixels = scl.eq(4).or(scl.eq(5)).or(scl.eq(6)).or(scl.eq(11));
      return image.updateMask(clear_sky_pixels).divide(10000);
};

I understand that in maskS2clouds method only cloudy pixels are removed, while in s2ClearSky also removes cloud shadows, thin cirrus, defective, etc. But, is there any other difference? Which of the two methods is better? Which one should I use in each case? What is the reason for using .select("B.*").copyProperties(image, ["system:time_start"]) in the first case? Are there better methods?

1

2 Answers 2

3

The SCL band used in the second function only exists in level-2A products. Its described here: https://sentinels.copernicus.eu/web/sentinel/technical-guides/sentinel-2-msi/level-2a/algorithm

The QA60 band used in the first function is described here: https://sentinels.copernicus.eu/web/sentinel/technical-guides/sentinel-2-msi/level-1c/cloud-masks

They are simply produced using different methods during different parts of the processing pipelines.

As explained in one of the comments though, there are even more methods for cloud masking in Sentinel-2, including using the s2cloudless collection, which is generated using yet another method (https://github.com/sentinel-hub/sentinel2-cloud-detector)

1

I think the best way of masking out the clouds in Sentinel-2 data is using the S2 cloud probability data. It has the 10m resolution while the QA60 has the 60m resolution. However SCL has the benefit of detecting cloud shadow (it also has the spatial resolution of 60m). So, it is all depends on kind of project that your are doing.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.