Sentinel-2 L2A Quarterly Cloudless Mosaic - NDWI Visualization Copernicus Browser Raw Values
//VERSION=3
//ndwi with kndvi
const colorRamp1 = [
[ 0 , 0xFFFFFF ], //Black
[ 0.7 , 0x008000 ] //Green (lower if you want a greener map)
];
const colorRamp2 = [
[ 0 , 0xFFFFFF ], //Black
[ 1 , 0x0000CC ] //Medium Blue
];
let viz1 = new ColorRampVisualizer ( colorRamp1 );
let viz2 = new ColorRampVisualizer ( colorRamp2 );
function setup () {
return {
input : [ " B03 " , " B04 " , " B08 " , " dataMask " ],
output : [
{ id : " default " , bands : 4 },
{ id : " index " , bands : 1 , sampleType : " FLOAT32 " },
{ id : " eobrowserStats " , bands : 1 , sampleType : ' FLOAT32 ' },
{ id : " dataMask " , bands : 1 }
]
};
}
function evaluatePixel ( samples ) {
let factor = 1 / 2000 ;
let Green = factor * samples . B03 ;
let Red = factor * samples . B04 ;
let NIR = factor * samples . B08 ;
let val = index ( Green , NIR );
let kndvi = Math . tanh ( Math . pow ((( NIR - Red ) / ( NIR + Red )), 2 )); //https://doi.org/10.1126/sciadv.abc7447
let imgVals = null ;
// The library for tiffs works well only if there is only one channel returned.
// So we encode the "no data" as NaN here and ignore NaNs on frontend.
const indexVal = samples . dataMask === 1 ? val : NaN ;
if ( val < - 0 ) {
imgVals = [... viz1 . process ( kndvi ), samples . dataMask ];
} else {
imgVals = [... viz2 . process ( Math . sqrt ( Math . sqrt ( val ))), samples . dataMask ];
}
return {
default : imgVals ,
index : [ indexVal ],
eobrowserStats :[ val ],
dataMask : [ samples . dataMask ]
};
}
//VERSION=3
function setup () {
return {
input : [ " B03 " , " B08 " , " dataMask " ],
output : [
{ id : " default " , bands : 4 },
{ id : " index " , bands : 1 , sampleType : " FLOAT32 " },
{ id : " eobrowserStats " , bands : 1 , sampleType : " FLOAT32 " },
{ id : " dataMask " , bands : 1 }
]
};
}
const colorRamp1 = [
[ 0 , 0xFFFFFF ],
[ 1 , 0x008000 ]
];
const colorRamp2 = [
[ 0 , 0xFFFFFF ],
[ 1 , 0x0000CC ]
];
const viz1 = new ColorRampVisualizer ( colorRamp1 );
const viz2 = new ColorRampVisualizer ( colorRamp2 );
function evaluatePixel ( samples ) {
let val = index ( samples . B03 , samples . B08 );
if ( val < 0 ) {
imgVals = viz1 . process ( - val )
} else {
imgVals = viz2 . process ( Math . sqrt ( Math . sqrt ( val )))
}
// The library for tiffs works well only if there is only one channel returned.
// So we encode the "no data" as NaN here and ignore NaNs on frontend.
const indexVal = samples . dataMask === 1 ? val : NaN ;
return {
default : imgVals . concat ( samples . dataMask ),
index : [ indexVal ],
eobrowserStats : [ val ],
dataMask : [ samples . dataMask ]
};
}
//VERSION=3
function setup () {
return {
input : [ " B03 " , " B08 " ],
output : {
bands : 1 ,
sampleType : " FLOAT32 "
}
};
}
function evaluatePixel ( samples ) {
return [ index ( samples . B03 , samples . B08 )]
}
Show full evalscript Evaluate and Visualize Collection Access Sentinel-2 L2A Quarterly Cloudless Mosaic is one of the Sentinel-2 products , that is offered in Copernicus Data Space Ecosystem . The data is accessible via Copernicus Browser . To access the data, you need a Copernicus Data Space Ecosystem account , and then either create a Sentinel Hub Process API request to the collection or to visualise the data via Copernicus Browser . The collection ID is 5460de54-082e-473a-b6ea-d5cbe3c17cca
, and the collection type is byoc-5460de54-082e-473a-b6ea-d5cbe3c17cca
.
General description The NDWI is used to monitor changes related to water content in water bodies. As water bodies strongly absorb light in visible to infrared electromagnetic spectrum, NDWI uses green and near infrared bands to highlight water bodies. It is sensitive to built-up land and can result in over-estimation of water bodies.
NDWI = (GREEN - NIR) / (GREEN + NIR)
For Sentinel-2, the index calculates as:
NDWI = (B03 - B08) / (B03 + B08)
See also this page .
Description of representative images NDWI of Iceland, 01.10.2023.