| 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 | |
| ] | |
| } | |
| } |