Learn how to use cloud masking and visualize Sentinel-2 imagery in Google Earth Engine. Includes scripts for RGB, NDVI, and true-color composites.
Sentinel-2 with cloud masking, developed by the European Space Agency (ESA), offers high-resolution multispectral imagery with a revisit time of just 5 days. It's one of the most popular datasets in Google Earth Engine (GEE) thanks to its 13 spectral bands, wide area coverage, and frequent updates.
But like most optical satellites, Sentinel-2 is affected by clouds, haze, and shadows, which can obscure land features. To get clean, usable imagery, cloud masking is a critical first step.
In this tutorial, you'll learn how to:
-
Load Sentinel-2 surface reflectance data
-
Mask clouds and cloud shadows using QA60 and SCL bands
-
Visualize imagery in true color, false color, and NDVI
1. Load Sentinel-2 SR Collection in GEE
We’ll use Level-2A (surface reflectance) data:
📦 Dataset ID: COPERNICUS/S2_SR
2. Cloud Masking Using QA60 Band (Bitmask Method)
The QA60 band contains cloud and cirrus information encoded as bits.
Cloud Mask Function:
Apply Cloud Mask:
3. Alternative Cloud Masking Using SCL Band (Scene Classification)
SCL is available only in Level-2A products. This band classifies each pixel (e.g., cloud, vegetation, water).
SCL-based Mask Function:
Apply:
SCL method is more flexible, especially for thematic classification.
4. Visualize Sentinel-2 in True Color
RGB (B4, B3, B2)
5. Visualize Sentinel-2 in False Color (Vegetation Highlight)
NIR, Red, Green (B8, B4, B3)
🌿 Healthy vegetation appears bright red.
6. Calculate and Visualize NDVI
NDVI is one of the most common vegetation indices, calculated as:
📈 You can also chart NDVI over time or export it for further analysis.
7. Best Practices for Sentinel-2 Visualization
Tip | Why It Matters |
---|---|
Use median() or mosaic() | Reduces cloud impact |
Apply cloud masking before calculations | Ensures data integrity |
Use scale = 10 when exporting | Matches Sentinel-2 spatial resolution |
Visualize with appropriate color palettes | Enhances interpretability |
Filter by CLOUDY_PIXEL_PERCENTAGE < 20 | Pre-selects best images |
8. Exporting Cloud-Free Images
Ideal for reports, map layouts, and temporal comparisons.
Conclusion
With proper cloud masking and visualization techniques, Sentinel-2 imagery in Google Earth Engine becomes a powerful tool for agriculture, forestry, urban monitoring, and environmental analysis. Using both QA60 and SCL-based methods, you can generate clean composites, calculate indices like NDVI, and export high-quality results.
By mastering these techniques, you ensure that your analysis is both visually accurate and scientifically reliable.
🔗 Related Articles:
Written by: Jamal Chaaouan | GEE Academy
COMMENTS