Send filtering data to custom Script from client

I have a NVDI WMS layer configured to show NDVI index, and I need to let the user choose the color ramp.
Is there a way to send parameters from the client and get then inside the evaluatePixel function?

According to reference this is the signature of the method, but I can’t find an example that uses inputMetadata or customData or a reference about their content.

function evaluatePixel(samples, scene, inputMetadata, customData, outputMetadata) {
}
Thank you

You can simply construct the whole EVALSCRIPT on the client and pass it to the WMS as a parameter, in these steps:

  1. Construct an EVALSCRIPT, e.g.
    return [B04];
  2. Base64 encode this script
    cmV0dXJuIFtCMDRdOw==
  3. Add it to the WMS request:
    https://services.sentinel-hub.com/wms/<INSTANCE_ID>?LAYER=NDVI&EVALSCRIPT=cmV0dXJuIFtCMDRdOw==&...

In this way you will override the original script of the NDVI layer.

You might also be interested in our JavaScript helper library:

As Grega said, the easiest way for user-defined color ramp is to generate the evalscript on the client side and pass it as a parameter.

There are also utility functions for evalscript that might come handy for defining the color ramp / color gradient in the evalscript (documentation here).

Use of inputMetadata, customData and outputMetadata is not necessary for this use-case, they are useful for more complex evalscript.

Cheers.