SATeo
Home › Educational Guides › Data Quality
Data Quality

Cloud Masking and Scene Classification Layer Filtering in Optical Imagery

Build reliable optical pipelines by combining Level-2A Scene Classification masks, probability thresholds, and multi-date outlier checks.

Why Scene-Level Cloud Percentages Are Not Enough

Filtering a catalog search with MAXCC <= 20% only checks the percentage of clouds across the entire 100 km x 100 km Sentinel-2 tile. A tile marked five percent cloudy overall can still place a thick cumulus cloud directly over your 200-hectare study site, while an eighty-percent cloudy tile might be completely clear over your target valley.

Production pipelines therefore query higher scene cloud limits—often 50% to 80%—and inspect pixel-level cloud masks inside the exact Area of Interest geometry. Counting valid clear pixels per polygon prevents wasted API queries and rescues dozens of usable clear observations every year.

  • Catalog cloudcover metadata applies to full MGRS tiles, not individual polygons
  • Level-2A products include a 20 m Scene Classification Layer (SCL) with 12 semantic classes
  • Thin cirrus (SCL 10) and dark cloud shadows (SCL 3) corrupt NDVI almost as badly as opaque clouds
  • Combining SCL masks with cloud probability (CLD/s2cloudless) catches edge haze

Decoding the Sentinel-2 Scene Classification Layer (SCL)

Generated by the Sen2Cor atmospheric processor, the SCL band classifies each 20-meter pixel into discrete integers from 0 to 11. Classes 4 (Vegetation), 5 (Not-Vegetated / Bare Soil), 6 (Water), and 7 (Unclassified low-probability) generally represent usable land or water observations, whereas classes 3 (Cloud Shadows), 8 (Cloud Medium Probability), 9 (Cloud High Probability), and 10 (Thin Cirrus) must be masked out.

Analysts working across alpine watersheds or winter latitudes must treat Class 11 (Snow / Ice) carefully: bright white roofs or dry salt pans occasionally misclassify as snow, while genuine snow cover should be excluded from growing-season vegetation averages.

Handling Residual Cloud Edges and Shadow Halos

No single-date pixel classifier achieves one hundred percent accuracy along soft cumulus margins. Semi-transparent cloud halos frequently slip through SCL class thresholds, depressing NDVI by 0.15 to 0.30 and creating sharp single-date dips in crop phenology curves.

Two simple techniques eliminate most halo leakage: spatial morphological dilation (buffering detected cloud and shadow masks outward by 1 to 2 pixels) and temporal outlier filtering using cloud-probability bands or rolling maximum/median smoothing across consecutive passes.

  • Reject pixels where cloud probability exceeds 20–30% even if SCL labels them clear
  • Check minimum valid-pixel fraction (e.g., >= 70% of polygon pixels clear) before accepting a date
  • Keep dark topographic shadows (SCL 2) under review in steep mountain terrain

Equivalents on Landsat Collection 2 and Harmonized Stacks

When working with Landsat 8 or 9 Collection 2 Level-2 scenes, the QA_PIXEL bitmask band serves the same role as Sentinel-2 SCL, encoding bit flags for Fill, Dilated Cloud, Cirrus, Cloud, Cloud Shadow, and Snow. Abstracting both sensors behind a unified boolean clear_mask inside your processing layer enables seamless cross-mission time series.

Sentinel-2 Level-2A Scene Classification Layer (SCL) Filtering Rules

SCL ValueClass LabelDefault Pipeline ActionEdge-Case Consideration
0 / 1No Data / Saturated or DefectiveMask / ExcludeAlways drop; corrupted sensor or tile border
2 / 3Dark Area / Cloud ShadowsMask Class 3; review 2Steep north-facing terrain shadows also map to Class 2
4 / 5 / 6Vegetation / Bare Soil / WaterKeep (Valid Clear)Core analytical land and surface water classes
7UnclassifiedConditional KeepMixed coastal or urban transitions; check CLD probability
8 / 9 / 10Cloud Med / High / Thin CirrusMask / ExcludeMandatory exclusion for reflectance and index math

SCL definitions follow the ESA Sen2Cor Level-2A Product Format Specification.

Worked Illustration: Polygon Clear-Pixel Gate Filtering

This worked illustration demonstrates how a Statistical API consumer decides whether a partially cloudy Sentinel-2 overpass is clean enough to include in a crop time series.

  1. Query a 120-hectare farm polygon containing 3,000 pixels at 20 m SCL grid spacing.
  2. Count pixels per SCL class on Date A: 2,460 pixels in classes {4, 5, 6}, 390 pixels in {8, 9, 10}, 150 pixels in {3}.
  3. Calculate valid clear fraction: 2,460 / 3,000 = 0.82 (82% clear inside the polygon).
  4. Compare against a 75% polygon clear threshold: Date A passes (82% >= 75%), and stats are computed strictly over the 2,460 unmasked pixels.

Worked Illustration Summary: Applying an 82% polygon clear gate preserves Date A while excluding the 540 cloud/shadow pixels from corrupting the parcel mean NDVI.

Optical Cloud Masking Verification Checklist

  • Set catalog search MAXCC generously (e.g., 60–80%) and filter clouds at polygon pixel level
  • Mask SCL classes 0, 1, 3, 8, 9, 10 (and 11 if snow-free vegetation is required)
  • Combine SCL masks with cloud probability thresholds (CLD < 25%) to catch soft cloud fringes
  • Track validSampleCount alongside totalSampleCount in Statistical API responses
  • Reject polygon dates with less than 70–80% clear coverage to prevent sampling bias
  • Use QA_PIXEL bitmask extraction when merging Landsat 8/9 into optical stacks

Frequently Asked Questions

Why does bright white concrete or sand sometimes get flagged as cloud in SCL?

High-albedo surfaces like limestone quarries, salt flats, or metal warehouse roofs reflect strongly across visible bands, mimicking cloud brightness. Combining thermal bands (Landsat) or temporal persistence checks reduces false cloud flags.

Should I mask SCL Class 2 (Dark Area Pixels)?

It depends on terrain. Over flat plains, Class 2 often catches unflagged cloud shadows; in mountainous regions, permanent north-facing slope shadows fall in Class 2 and masking them may create persistent data holes.

How do I clean residual dips that slip past cloud masks in NDVI charts?

Apply a temporal rolling maximum or Savitzky-Golay upper-envelope filter across consecutive dates, since clouds almost always depress NDVI downward rather than inflating it.

Can I use s2cloudless probability on Level-1C as well as Level-2A?

Yes. Machine-learning cloud detectors trained on Sentinel-2 top-of-atmosphere bands work directly on Level-1C data and are exposed as cloud probability layers in cloud EO platforms.

Primary Standards & Technical References

  • ESA Sen2Cor Algorithm Theoretical Basis Document (ATBD) — Scene Classification Module
  • USGS Landsat 8–9 Collection 2 Level-2 QA_PIXEL Bitmask Specification (U.S. Geological Survey)
  • Skakun, S. et al. — Cloud Mask Intercomparison eXercise (CMIX) Benchmark (Remote Sensing of Environment)

Related Earth Observation Guides