L2A scene classification for Sentinel-2


#1

It is now possible to get information from scene classification layer produced by Sen2Cor, for data where L2A is available, of course.

Data can be retrieved by identifier “SCL” (e.g. instead of return [B02]; for blue color one can use return [SCL];).
Data can be then used for e.g. validation of the pixel value, e.g. along the lines:

function validate (samples) {
  var scl = Math.round(samples.SCL);
  
  if (scl == 3) { // SC_CLOUD_SHADOW
    return false;
  } else if (scl == 9) { // SC_CLOUD_HIGH_PROBA
    return false; 
  } else if (scl == 8) { // SC_CLOUD_MEDIUM_PROBA
    return false;
  } else if (scl == 7) { // SC_CLOUD_LOW_PROBA
    //return false;
  } else if (scl == 10) { // SC_THIN_CIRRUS
    return false;
  } else if (scl == 11) { // SC_SNOW_ICE
    return false;
  } else if (scl == 1) { // SC_SATURATED_DEFECTIVE
    return false;
  } else if (scl == 2) { // SC_DARK_FEATURE_SHADOW
    // return false;
  }
  return true;
}

Important remark - it makes sense to use this layer only on full resolution as any interpolation based on classification codelist will not produce reasonable results. You should also use NEAREST upsampling/downsampling setting.
Note that this feature is in prototype mode and its behavior can change a bit in the future, based on lessons learned.


#2

A “Scene classification map” is now available as a layer in EO Browser whenever Sentinel2-L2A dataset is visualized. E.g., check out how the classification map looks like around lake Ohrid: https://apps.sentinel-hub.com/eo-browser/#lat=41.07663&lng=20.53431&zoom=13&time=2018-07-06&preset=SCENE-CLASSIFICATION-MAP&datasource=Sentinel-2%20L2A

The Scene classification map is a result of Scene classification algorithm by ESA, which is described here: https://sentinel.esa.int/web/sentinel/technical-guides/sentinel-2-msi/level-2a/algorithm

The script currently used for visualization in EO Browser is:

 function RGBToColor (a, b, c){
	return [a/255, b/255, c/255];
}

switch (SCL) {
  // No Data (Missing data) (black)    
  case 0: return RGBToColor (0, 0, 0);
    
  // Saturated or defective pixel (red)   
  case 1: return RGBToColor (255, 0, 0);

  // Dark features / Shadows (very dark grey)
  case 2: return RGBToColor (47,  47,  47);
    
  // Cloud shadows (dark brown)
  case 3: return RGBToColor (100, 50, 0);
    
  // Vegetation (green)
  case 4: return RGBToColor (0, 160, 0);
    
  // Not-vegetated (dark yellow)
  case 5: return RGBToColor (255, 230, 90);
    
  // Water (dark and bright) (blue)
  case 6: return RGBToColor (0, 0, 255);
  
  // Unclassified (dark grey)
  case 7: return RGBToColor (128, 128, 128);
  
  // Cloud medium probability (grey)
  case 8: return RGBToColor (192, 192, 192);
    
  // Cloud high probability (white)
  case 9: return RGBToColor (255, 255, 255);
  
  // Thin cirrus (very bright blue)
  case 10: return RGBToColor (100, 200, 255);
    
  // Snow or ice (very bright pink)
  case 11: return RGBToColor (255, 150, 255);

  default : return RGBToColor (0, 0, 0);  
}