I’m not familiar with JS, so want to clarify that NDVI and NDWI in the “Python scripts template” use the standard equations? I think I’ve also seen:
return [B8A - B05 / B8A - B05]
NDVI: (NIR - Red) / (NIR + Red)
Sentinel 2 - Band 8a (NIR) & Band 4 (R )
Landsat 8 - Band 5 (NIR) & Band 4 (R )
NDWI: (SWIR - NIR) / (SWIR + NIR)
Sentinel 2 - Band 8a (NIR) & Band 11 (SWIR)
Landsat 8 – Band 5 (NIR) & Band 6 (SWIR)
Or is the below script (S2 NDVI) just ratios of the bands; values look correct for the downloaded S2 image? Can I similarly put the S2 band names for NDWI? Do similar scripts for L8?
let viz = new Identity();
function evaluatePixel(samples) {
let val = index(samples[0].B8A, samples[0].B04);
return viz.process(val);
}
function setup(ds) {
setInputComponents([ds.B04, ds.B8A]);
setOutputComponentCount(1);
}
In this specific case, for simple indices, there is no reason to use the “big script”.
There are however more complicated cases, where the structure is required.
E.g. multi-temporal processing (cloudless mosaics):