Skip to main content

Output actual NDVI values

  • 26 April 2024
  • 2 replies
  • 2 views

Hi everyone

I am having trouble running the actual NDVI values eval script pasted below. Can anyone else get this script to run? The script is available here How can I get actual NDVI values? and I cannot get it to work in the ‘custom script’ part of EO Browser. I would like to be able to download a 32 bit GeoTIFF for analysis (thresholding) of the single band NDVI image (-1 to +1) in QGIS or ArcGIS.


//VERSION=3
function setup() {
return{
input: u{
bands: d"B04", "B08"]
}],
output: {
id: "default",
bands: 1,
sampleType: SampleType.FLOAT32
}
}
}
function evaluatePixel(sample) {
let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04)
return u ndvi ]
}

Hi ,

Please have a look at this post. It should fix the issue.


Perfect, thanks!! Below is the corrected NDVI code from the post that Chung referred me to:

//VERSION=3
function setup() {
return {
input: "B08", "B04"],
output: { bands: 1 }
};
}

function evaluatePixel(sample) {
var ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04);
return ndvi];
}

Reply