File size: 1,530 Bytes
64ab846
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function setup() {
        return {
            input: [{
                bands: [
                        "B02",
                        "B03",
                        "B04",
                        "B08",
                        //"CLM"
                        "SCL"   // instead of CLM. it is the scene classification
                        ],
                units: ["reflectance", "reflectance", "reflectance", "reflectance", "DN"]
            }],
            output: [
            {
                id: 'rgb_nir',
                bands: 5,
                //sampleType: "UINT8"
            }]
        };
    }

//function updateOutput(output, collection) {
//    output.my_output.bands = collection.scenes.length
//}


//function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
//    outputMetadata.userData = { "scenes":  scenes.orbits }
//}

// final shape as RGB-NIR
    function evaluatePixel(sample) {
    // DO NOT CHANGE BAND ORDER --> REQUIRED FOR VI CALCULATION
    let red = sample.B04
    let green = sample.B03
    let blue = sample.B02
    let nir = sample.B08
    let cloud_mask = ([8, 9, 10].includes(sample.SCL)) ? 1 : 0; // this classes correspond to clouds
    //let cloud_mask = sample.CLM
        return {
                rgb_nir: [
                            red,
                            green,
                            blue,
                            nir,
                            cloud_mask
                ]
        }
    }