I applied the cloud masking on Sentinel 2 imagery in GEE. The original image collection without masking clouds is this:

enter image description here

First I tried the script exactly as written at the bottom of this page Sentinel-2 MSI: MultiSpectral Instrument, Level-2A and I got this result:

enter image description here

I saw other tutorials that other people use median, so the second time I deleted 'mean' in the last line here:

Map.addLayer(dataset.mean(), visualization, 'RGB');

Instead I added 'median' in the image collection variable:


And this is the result: enter image description here

I realized median () produces much clearer image, however I am not sure about differences between median () and meanand since mean was used in the GEE website, I do not know if I am doing right by using median and having such a clear image!

  • 1
    If your objective is to have a less cloudy image, the median is fine, it is commonly used. Think about it as a series of values, where every value is a pixel on a different date. If you apply the min, max, mean, median, etc. What you are doing is selecting the pixel that matches that statistic on the time series.
    – OscarBau
    Commented Jun 1, 2021 at 20:16


Your Answer

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