function setup() { return { input: [{ bands: [ "B02", // Blue "B03", // Green "B04", // Red "B05", // Vegetation red edge, 704.1 nm (S2A), 703.8 nm (S2B) "B06", // Vegetation red edge, 740.5 nm (S2A), 739.1 nm (S2B) "B08", // Nir-Infrared "B11", // SWIR (20m res) "SCL" // instead of CLM. it is the scene classification //"dataMask" ], units: 'DN' // "reflectance" //For Sentinel-2, digital numbers are divided by 10,000 to get reflectance. If you want to calculate //normalized difference indices for optical bands scaling is relevant. In such cases, //it makes sense to use digital numbers (DN) as units. Doing so will be very slightly faster since reflectance //conversion will be avoided. }], output: [ { id: "vi_values", bands: 25, sampleType: SampleType.FLOAT32 } ] }; } // final shape as RGB-NIR function evaluatePixel(sample) { let cloud_mask = ([8, 9, 10].includes(sample.SCL)) ? 1 : 0; // this classes correspond to clouds let ndvi = (sample.B08 - sample.B04)/(sample.B08 + sample.B04); let grvi = (sample.B08) / (sample.B03); let rvi = (sample.B08) / (sample.B04); let rgi = (sample.B04) / (sample.B03); let aci = (sample.B03) / (sample.B08); let maci = (sample.B08) / (sample.B03); let gndvi = (sample.B08 - sample.B03) / (sample.B08 + sample.B03); let ngrdi = (sample.B03 - sample.B04) / (sample.B03 + sample.B04); // also know as mngrdi let ngbdi = (sample.B03 - sample.B02) / (sample.B03 + sample.B02); // let rgbvi = () / () rgbvi = (np.square(self.green.astype(float)) - (self.red.astype(float) * self.blue.astype(float))) / (np.square(self.green.astype(float)) + (self.red.astype(float) * self.blue.astype(float))) let bgvi = (sample.B02) / (sample.B03); let brvi = (sample.B02) / (sample.B04); // exg = (2 * self.green.astype(float)) - self.red.astype(float) - self.blue.astype(float) let wi = (sample.B03 - sample.B02) / (sample.B04 - sample.B03); let varig = (sample.B03 - sample.B04) / (sample.B03 + sample.B04 - sample.B02 ); let gli = (sample.B03 + sample.B03 - sample.B04 - sample.B02) / (sample.B03 + sample.B03 + sample.B04 - sample.B02); //tgi = (self.green.astype(float) - 0.39 * self.red.astype(float) - 0.61 * self.blue.astype(float)) //twoGRGi = (self.green.astype(float) + self.green.astype(float) - self.red.astype(float) - self.blue.astype(float)) let g_perc = (sample.B03) / (sample.B03 + sample.B04 + sample.B02); //let cloud_mask = sample.CLM; // let data_mask = sample.dataMask; no apparent benefit let ndmi = (sample.B08 - sample.B11) / (sample.B08 + sample.B11);//Sentinel-2 NDMI = (B08 - B11) / (B08 + B11) - https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2/ndmi/ let ndwi = (sample.B03 - sample.B08) / (sample.B03 + sample.B08); //Sentinel-2 NDWI = (B03 - B08) / (B03 + B08) - https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2/ndwi/ // // same as ndwi (normalized difference moisture index and normalized difference water index) // https://eos.com/blog/vegetation-indices/ let reci = (sample.B08 / sample.B04) - 1;// (NIR / RED) – 1 let ndre_lower_end = (sample.B08 - sample.B05) / (sample.B08 + sample.B05); // (NIR – RED EDGE) / (NIR + RED EDGE) let ndre_upper_end = (sample.B08 - sample.B06) / (sample.B08 + sample.B06); let msavi = (2 * sample.B04 + 1 - Math.sqrt((2 * sample.B04 + 1) ** 2 - 8 * (sample.B04 - sample.B03))) / 2; // (2 * Band 4 + 1 – sqrt ((2 * Band 4 + 1)2 – 8 * (Band 4 – Band 3))) / 2 // let savi = ((NIR – red) / (NIR + red + L)) * (1 + L) // NOT WORKING WITH 0.16 SUMMED TO INT let osavi = (sample.B08 - sample.B04)/(sample.B08 + sample.B04 + 0.16) (NIR – red) / (NIR + red + 0.16) 0.16 is default soil-adjustment factor (default is 0.5) let arvi = (sample.B08 - (2 * sample.B04) + sample.B02) / (sample.B08 + (2 * sample.B04) + sample.B02); // (NIR – (2 * RED) + BLUE) / (NIR + (2 * RED) + BLUE) // NOT WORKING WITH 1 SUMMED TO INT let evi = // 2.5 * ((NIR – RED) / ((NIR) + (C1 * RED) – (C2 * BLUE) + L)) with C1=6, C2=7.5, and L=1 // LAI let sipi = (sample.B08 - sample.B02) / (sample.B08 + sample.B02); // (NIR – BLUE) / (NIR – RED) let gci = (sample.B08 / sample.B02) -1; // NIR / GREEN – 1 return { vi_values: [cloud_mask, ndvi, grvi, rvi, rgi, aci, maci, gndvi, ngrdi, ngbdi, bgvi, brvi, wi, varig, gli, g_perc, ndmi, ndwi, reci, ndre_lower_end, ndre_upper_end, msavi, arvi, sipi, gci ] } }