How to get statistical info about ndvi from sentinel-3-OLCI

for sentinel-3-OLCI, i am using the below posted evalscript to have statistical information using statistical-api.
please let me know why the app crashes when attempts to process the evalscript?

evalscript:

const evalscript = 
`
//VERSION=3

function setup() {
    return {
      input: [{
        bands: ["B08", "B17", "dataMask"],
        units: "DN"
      }],
      output: [
        {
          id: "ndvi", 
          bands: 1,
        },
        {
          id: "dataMask", 
          bands: 1,
        }
      ]
    }

  }

  function evaluatePixel(samples) {
    // Precompute an array to contain NDVI observations

    if (!samples) {
      return {
        ndvi: [NaN], 
        dataMask: [NaN]
      };
    }
    if (samples.length < 1) {
      return {
        ndvi: [NaN], 
        dataMask: [NaN]
      };
    }

    let index = null;
    if (samples.B17 + samples.B08 === 0) {
      index = 0; // to avoid division by zero
      return {
        ndvi: [index],
        dataMask: [samples.dataMask]
      };
    }
    index = (samples.B17 - samples.B08) / (samples.B17 + samples.B08);

    return {
      ndvi: [index],
      dataMask: [samples.dataMask],
    };
}`

Hi,

For the data collection you are using, checking the docs, Digital Numbers: DN are not available as an input parameter. In future, as I am sure you know, you can test your scripts in Request Builder (which is where I found the error message pointing me to this.

thank you
your help is appreciated

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