Hey,
regarding the support of NaN
s in the evalscript and in tiff images, yes, this can be done. A problem may arise when you want to process the data. I didn’t try all possibilities in QGIS, but displaying tiff image with only 1 channel, it automatically marks (displays) NaN
s as transparent.
Example evalscript that works (change the id of the output to default
here in evalscript or set the id of the desired output in the request params (output
→ responses
; docs)):
//VERSION=3
function setup() {
return {
input: ["B01","B02", "dataMask"],
output: [
{ id: "index", bands: 1, sampleType: 'FLOAT32' }
]
};
}
function evaluatePixel(samples) {
let index = (samples.B01-samples.B02)/(samples.B01+samples.B02);
// encode "no data" as NaN
const indexVal = samples.dataMask === 1 ? index : NaN;
return { index: [indexVal] };
}
One more general note: If you are processing tiff images in javascript and use geotiff.js, geotiff.js will correctly parse data only from the last channel of images retrieved from Sentinel Hub. This didn’t pose an issue for us yet because we use geotiff.js to parse tiff images with indexes and we only need 1 channel for that. Here is the issue in geotiff.js’s GitHub repository with more information.
Hope this helps.
Cheers.