HLS Statistical Requests Builder Default evalscript: Output dataMask requested but missing from function setup()

Hello, I am using the default evalscript and request for the HLS collection for the Statistical API via the requests builder. The default evalscript looks like this:

//VERSION=3

function setup() {
  return {
    input: ["Blue", "Green", "Red"],
    output: { bands: 3 }
  };
}

function evaluatePixel(sample) {
  return [2.5 * sample.Red, 2.5 * sample.Green, 2.5 * sample.Blue];
}

I already tried modifying the script like so, but I am still getting the same error:

//VERSION=3

function setup() {
  return {
    input: ["Blue", "Green", "Red", "dataMask"],
    output: { bands: 4 }
  };
}

function evaluatePixel(sample) {
  return [2.5 * sample.Red, 2.5 * sample.Green, 2.5 * sample.Blue, sample.dataMask];
}

How can I get a functional request for HLS data for the Statistical API?

Hi,

Please note that there are adjustments you need to make to an evalscript to use it with Statistical API:

All general rules for building evalscripts apply. However, there are some specifics when using evalscripts with the Statistical API:

  • The evaluatePixel() function must, in addition to other output, always return also dataMask output. This output defines which pixels are excluded from calculations. For more details and an example, see here.
  • The default value of sampleType is FLOAT32.
  • The output.bands parameter in the setup() function can be an array. This makes it possible to specify custom names for the output bands and different output dataMask for different outputs, see this example.

You should be able to adapt this example to meet your needs.

For additional info, please consult the docs.

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