Output actual NDVI values

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: [{
          bands: ["B04", "B08"]
        }],
        output: {
          id: "default",
          bands: 1,
          sampleType: SampleType.FLOAT32
        }
      }
    }
    function evaluatePixel(sample) {
      let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04)
      return [ ndvi ]
    }

Hi @ivars.reinfelds ,

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

Perfect, thanks @chung.horng!! 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];
}

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.