RasterScaling

The raster scaling operator scales/unscales the values of a raster by a given slope factor and offset. This allows to shrink and expand the value range of the pixel values needed to store a raster. It also allows to shift values to all-positive values and back. We use the GDAL terms of scale and unscale. Raster data is often scaled to reduce memory/storage consumption. To get the "real" raster values the unscale operation is applied. Keep in mind that scaling might reduce the precision of the pixel values. (To actually reduce the size of the raster, use the raster type conversion operator and transform to a smaller datatype after scaling.)

The operator applies the following formulas to every pixel.

For unscaling the formula is: p_new = p_old * slope + offset.

For scaling the formula is: p_new = (p_old - offset) / slope

p_old and p_new refer to the old and new pixel value. The slope and offset values are either properties attached to the input raster or a fixed value.

An example for Meteosat Second Generation properties is:

  • offset: msg.calibration_offset
  • slope: msg.calibration_slope

Parameters

ParameterTypeDescriptionExample Value
slopeMetadataKeyOrConstantthe key or value to use for slope{"type": "metadataKey" "domain": "", "key": "scale" }
offsetMetadataKeyOrConstantthe key or value to use for offset{"type": "constant" "value": 0.1 }
scalingModescale OR unscaleselect scale or unscale mode"scale"
outputMeasurement*(optional) Measurementthe measurement of the data produced by the operator{"type": "continuous", "measurement": "Reflectance","unit": "%"}

* if no outputMeasurement is given, the measurement of the input raster is used.

The RasterScaling operator expects exactly one raster input.

ParameterType
sourceSingleRasterSource

Types

The following describes the types used in the parameters.

MetadataKeyOrConstant

The MetadataKeyOrConstant type is used to specify a metadata key or a constant value.

ValueDescription
{"type": "constant", "value": number}A constant value.
{"type": "metadataKey", "domain": string, "key": string}A metadata key to lookup dynamic values from raster (tile) properties.

Example JSON

{
  "type": "RasterScaling",
  "params": {
    "slope": {
      "type": "metadataKey",
      "domain": "",
      "key": "scale"
    },
    "offset": {
      "type": "value",
      "value": 1.0
    },
    "outputMeasurement": null,
    "scalingMode": "scale"
  },
  "sources": {
    "source": {
      "type": "GdalSource",
      "params": {
        "data": {
          "type": "internal",
          "datasetId": "00000000-0000-0000-0000-000000000539"
        }
      }
    }
  }
}