SIGN IN

Planet Completes Acquisition of Sinergise; Set to Expand Planet’s Earth Data Platform

In Sentinel Hub, the calculated and output values depend on what users specify in their evalscripts (or custom scripts). By calculated values we are referring to the values that are returned from the evaluatePixel() function or from a simple script. Output values are values returned from Sentinel Hub, after the calculated values go through formatting defined by sampleType. In the evalscript, calculated and output values are controlled by:

  • In the setup() function, the requested bands and units define what values are used as input for the calculation (in simple scripts, default units are used). For example, if Sentinel–2 band B04 is requested in REFLECTANCE, the input values will be in the range 0–1. If Sentinel–2 band B04 is requested in DN (digital numbers), the input values for the calculation will be in the range 0–10000. Typical value ranges can be found in our data documentation, chapter Units for each data collection.
  • The evaluatePixel() function defines the actual calculation (in simple scripts, the entire script is its equivalent). Sentinel Hub uses double precision for all calculations and rounds only the final calculated values before they are outputted.
  • The value of the sampleType parameter in the setup() function define the format of the output values. Possible values are AUTO, UINT8, UINT16 and FLOAT32. See our sampleType documentation for more details. When the sampleType is not specified (e.g. in simple scripts), the default value AUTO will be used. sampleType.AUTO takes calculated values from the interval 0–1 and stretch them to 0– 255. If your calculated values are not in the range 0–1, make sure you either scale them to this range in the evaluatePixel() function or specify another sampleType.

Example 1: NDVI

In this example, we want to output values of the NDVI index, calculated based on Sentinel–2 data. Our evaluatePixel() function is:


function evaluatePixel(sample) {
    let NDVI =  (sample.B08 – sample.B04)/( sample.B08 + sample.B04)
    return [NDVI]
}

The requested units in this example do not have any influence on the calculated values of the NDVI. The output values returned by Sentinel Hub (black values in the table) for different sampleTypes are:

Calculated ValuesampleType.AUTOsampleType.UINT8sampleType.UINT16sampleType.FLOAT32
-1000-1
00000
0.2564000.25
1255111

Use sampleType:“FLOAT32” to return full floating -1 to 1 values. See the example here.

If you do not need values, but a vizualization, you can use sampleType:“AUTO”, but make sure to either:

  • map the NDVI values to the 0–1 interval in the evaluatePixel() function, e.g.:

    
    function evaluatePixel(sample) {
        let NDVI =  (sample.B08 – sample.B04)/( sample.B08 + sample.B04)
        return [(NDVI+1)/2]
    }
  • use a visualizer or a color visualization function, e.g. valueInterpolate.

Example 2: Sentinel–2 band B04

In this example, we want to output raw values of Sentinel–2 band 4. Our evaluatePixel() function looks like this:

function evaluatePixel(sample) {
     return [sample.B04]
}

If we request units: “REFLECTANCE”, the output values returned by Sentinel Hub (black values in the table) for different sampleTypes are:

Calculated ValuesampleType.AUTOsampleType.UINT8sampleType.UINT16sampleType.FLOAT32
00000
0.2564000.25
0.5128110.5
1255111
1.05255111.05

If we request units: “DN”, the output values returned by Sentinel Hub (black values in the table) for different sampleTypes are:

Calculated ValuesampleType.AUTOsampleType.UINT8sampleType.UINT16sampleType.FLOAT32
00000
250025525525002500
500025525550005000
100002552551000010000
105002552551050010500

Example 3: Brightness Temperature Bands

Here we output a Sentinel–3 SLSTR band F1 with typical values between 250–320 representing brightness temperature in Kelvin. The evaluatePixel() function is:


function evaluatePixel(sample) {
    return [sample.F1]
}

The output values returned by Sentinel Hub (black values in the table) for different sampleTypes are:

Calculated ValuesampleType.AUTOsampleType.UINT8sampleType.UINT16sampleType.FLOAT32
250255250250250
255255255255255
275.3255255275275.3
320255255320320

Use sampleType:“FLOAT32” to return original values. If integer values are still acceptable for your application, use sampleType:“UINT16”.

If you do not need values but a vizualization, you can use sampleType:“AUTO”, but make sure to either:

  • map the values to the 0–1 interval in the evaluatePixel() function, e.g.:

    
    function evaluatePixel(sample) {
        return [sample.F1/320]
    }
    
  • use a visualizer or a color visualization function, e.g. valueInterpolate.