SIGN IN

Sentinel Hub allows you to define custom JavaScript code for processing the layers before they are fetched via WMS, WMTS or other protocols.

Note: Examples of custom processing scripts can be found at https://custom-scripts.sentinel-hub.com/

Usage

Part of every WMS/WMTS/... request to our services are parameters instance id and layer. To obtain them, you need to log into the WMS Configurator to create suitable configurations. Combination of instance id and layer determines the data source and the script (either predefined or custom). The layer's script can also be overriden via EVALSCRIPT URL parameter when doing a WMS/WMTS/... request.

Scripts are executed inside a JavaScript engine and can use standard JS functions. There are 2 styles of writing the scripts, basic and extended. The system determines the type of script automatically when executing it.

Note: EOCloud service supports basic scripts (and ES5) only. AWS services support both basic and extended scripts.

Basic scripts

Basic scripts are run once for each pixel. They get the inputs through global variables and return an array of values.

Note: for more complex setup you should use extended scripts where supported, especially if you use Visualizers.

Inputs:

Available inputs depend on data source:

Data sourceAvailable inputs
Sentinel-2 L1CB01, B02, B03, B04, B05, B06, B07, B08, B8A, B09, B10, B11, B12
Sentinel-2 L2AB01, B02, B03, B04, B05, B06, B07, B08, B8A, B09, B11, B12, SCL*, SNW**, CLD**
Sentinel-1 GRDVV, VH, HH, HV
Sentinel-3 OLCI***

B01, B02, B03, B04, B05, B06, B07, B08, B09, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21

Sentinel-5P***

O3, NO2, SO3, CO, CH4, HCHO, AER_AI_340_380, AER_AI_354_388, CLOUD_FRACTION, CLOUD_BASE_HEIGHT, CLOUD_BASE_PRESSURE, CLOUD_OPTICAL_THICKNESS, CLOUD_TOP_HEIGHT, CLOUD_TOP_PRESSURE

Landsat 8 L1CB01, B02, B03, B04, B05, B06, B07, B08, B09, B10, B11, BQA
MODISB01, B02, B03, B04, B05, B06, B07
DEMDEM

*SCL: More info

** SNW and CLD bands are experimental and should not be used (they are subject to change without notice)

*** Only basic scripts are supported for these data sources

Please see data sources (and the corresponding EO products) for further information on the available input data.

Result:

Script must return an array of values. The length of the returned array is not prescribed by the system, but it must obey the following constraints:

  • length of array must be the same on every invocation of script
  • length of array must be supported by output format (1 or 3 for JPG and PNG, arbitrary for TIFF)

Often an array of a single value is returned (for example NDVI or some other indicator), or 3 values if one wants to visualize layer in RGB - but this depends on the use case and the client software.

Interpretation of returned values depends on output format:

  • TIFF8, TIFF16, PNG, JPG: values are mapped so that range [0..1] maps to range [min..max] (0..65535 for TIFF16, 0..255 for other formats); values under 0.0 or over 1.0 are set to 0.0 and 1.0 respectively.
  • TIFF32F: values are returned directly (as float32)

More info on output formats here.

Example script:

return [
    B04 * 2.5 + Math.max(0, B12 - 0.1),
    B03 * 2.5 + Math.max(0, B11 - 0.1),
    B02 * 2.5
];

Etna volcano eruption, dated 16. 3. 2017. Image combined from true colour image, overlaid with SWIR bands 11 and 12. (view in Sentinel Playground)