Raster Scaling
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. The key for this mode is mulSlopeAddOffset.
For scaling the formula is: p_new = (p_old - offset) / slope. The key for this mode is subOffsetDivSlope.
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
*if no outputMeasurement is given, the measurement of the input raster is used.
Parameters
Section titled “Parameters”| Name | Type | Description | Examples |
|---|---|---|---|
| slope | SlopeOffsetSelection | The slope (multiplication factor) applied to each pixel value. | {"domain":"","key":"scale"}{"value":0.1}{"type":"metadataKey","domain":"","key":"scale"} |
| offset | SlopeOffsetSelection | The offset (addition) applied to each pixel value. | {"domain":"","key":"scale"}{"value":0.1}{"type":"constant","value":1} |
| outputMeasurement | null or Measurement | null |
|
| scalingMode | ScalingMode | Selects whether the values are scaled or unscaled. | "mulSlopeAddOffset" |
Sources
Section titled “Sources”| Name | Type | Description |
|---|---|---|
| raster | RasterOperator | An operator that produces raster data. |
Examples
Section titled “Examples”{ "type": "RasterScaling", "params": { "slope": { "type": "metadataKey", "domain": "", "key": "scale" }, "offset": { "type": "constant", "value": 1 }, "outputMeasurement": null, "scalingMode": "mulSlopeAddOffset" }, "sources": { "raster": { "type": "GdalSource", "params": { "data": "modis-b6" } } }}