Clouds classification script

function S (a, b) { return a - b };
function R (a, b) { return a / b };

let gain = 2.5;

let naturalColour = [B04, B03, B02].map(a => gain * a);

let CLEAR  = naturalColour;
let SHADOW = naturalColour;
let WATER  = [0.1,0.1,0.7];
let CIRRUS = [0.8,0.1,0.1];
let CLOUD  = [0.3,0.3,1.0];
let SNOW   = [1.0,0.8,0.4];

return (B03 < 0.319)
? (B8A < 0.166)
    ? (S(B03,B07) < 0.027)
        ? (S(B09,B11) < -0.097) ? CLEAR : SHADOW
        : (S(B09,B11) < 0.021) ? WATER : SHADOW
    : (R(B02,B10) < 14.689)
        ? (R(B02,B09) < 0.788) ? CLEAR : CIRRUS
        : CLEAR
: (R(B05,B11) < 4.33)
    ? (S(B11, B10) < 0.255)
        ? (S(B06, B07) < -0.016) ? CLOUD : CIRRUS
        : (B01 < 0.3) ? CLEAR : CLOUD
    : (B03 < 0.525)
        ? (R(B01, B05) < 1.184) ? CLEAR : SHADOW
        : SNOW;

Evaluate and Visualize

General description

A paper about cloud detection [1], shows a fairly complex classification decision tree (figure 8 in the article), based on derived feature space resulting in 91% of correctly classified spectra.

The decision tree from [1][1]

The colours correspond to the colours from the article, apart from the colours for clear and shadow, which are made into natural (true) colour from red, green and blue bands.

Description of representative images

Hollstein cloud detection, Slovenia. Acquired on 9.10.2017.

Hollstein

References

[1] A. Hollstein et al., Ready-to-Use Methods for the Detection of Clouds, Cirrus, Snow, Shadow, Water and Clear Sky Pixels in Sentinel-2 MSI Images. Remote Sensing (2016). 10.3390/rs8080666