fmeobjects.FMERasterTools.convertInterpretation
- FMERasterTools.convertInterpretation(mode, interpretation, raster, parms)
Converts data type of a raster.
There are many assumptions on the input raster and the parameters:
- In RASTER mode
When converting to RGB / RGBA, the input raster must contain exactly 1, 3, or 4 bands.
When converting from 4 bands to RGB while trying to apply alpha, the 4 bands must be RGBA. If they are not, make this conversion in two steps (4 bands to RGBA, then RGBA to RGB).
When averaging multiple bands (converting to a single band), scaling by data values or data type is not permitted. Again, the same behavior can be achieved in a two-step conversion : RGB48 to Gray16, which is then scaled by data type to Gray8 for example.
- In PALETTE mode
All selected bands must have at least one selected palette.
- Parameters:
mode (int) –
Specifies what the conversion will work on, the raster, the bands, or the palettes. The Legacy mode should not be used. Choose one of:
FME_REINTERPRET_MODE_RASTER
FME_REINTERPRET_MODE_BAND
FME_REINTERPRET_MODE_PALETTE
interpretation (int) –
Desired interpretation of a raster after processing. Choose one of:
FME_INTERPRETATION_NULL
FME_INTERPRETATION_REAL64
FME_INTERPRETATION_REAL32
FME_INTERPRETATION_UINT64
FME_INTERPRETATION_INT64
FME_INTERPRETATION_UINT32
FME_INTERPRETATION_INT32
FME_INTERPRETATION_UINT16
FME_INTERPRETATION_INT16
FME_INTERPRETATION_UINT8
FME_INTERPRETATION_INT8
FME_INTERPRETATION_GRAY8
FME_INTERPRETATION_GRAY16
FME_INTERPRETATION_RED8
FME_INTERPRETATION_RED16
FME_INTERPRETATION_GREEN8
FME_INTERPRETATION_GREEN16
FME_INTERPRETATION_BLUE8
FME_INTERPRETATION_BLUE16
FME_INTERPRETATION_ALPHA8
FME_INTERPRETATION_ALPHA16
FME_INTERPRETATION_RGB24
FME_INTERPRETATION_RGBA32
FME_INTERPRETATION_RGB48
FME_INTERPRETATION_RGBA64
FME_INTERPRETATION_STRING
raster (FMERaster) – The raster to apply conversion to.
parms (dict[str, str]) – (Optional) Name-value pair representing additional parameters.
Possible parms are :
kFME_ConvertInterpretation_manyToOneBand
(Default) Averages all given bands into a single one.
kFME_ConvertInterpretation_RGBAToRGB
(Default) Discards the alpha band in RGBA to RGB conversions.
Multiplies all RGB values with their corresponding, normalized alpha value.
kFME_ConvertInterpretation_RGBToRGBA
(Default) Creates a new alpha band which has the maximum value for the data type in all cells.
Creates a new alpha band which has the maximum value for the data type only in data cells. A cell is considered to be nodata when, for each selected band, the value for that cell is equal to that band’s nodata value. If any cell value is not equal to that band’s nodata value, the cell will be considered data. Note that when this option is selected, it is required that all input bands have a nodata value.
kFME_ConvertInterpretation_colorToColor
Uses C-style casts to convert the values.
Uses C-style casts to convert the values, but also validates that the source values fit into the destination type, effectively preventing underflow and overflow; if a source value does not fit, the corresponding destination value will either be set to its type’s minimum or maximum value.
Finds the minimum and maximum values of the source values and uses them to scale the values to the full range of the destination type.
(Default) Scales the source values while preserving all proportions in regard to the source and destination types’ range.
kFME_ConvertInterpretation_colorToNumeric
Same possible values as
kFME_ConvertInterpretation_colorToColor
Defaults to BOUNDED_CAST
kFME_ConvertInterpretation_numericToColor
Same possible values as
kFME_ConvertInterpretation_colorToColor
kFME_ConvertInterpretation_numericToNumeric
Same possible values as convertInterpretation_colorToColor`
kFME_ConvertInterpretation_floatToInteger
(Default) Rounds to floating-point value to the nearest integer.
Gets the next integer which is greater than or equal to the floating-point value.
Gets the next integer which is less than or equal to the floating-point value.
- Return type:
- Returns:
The raster after converting the interpretation.
- Raises:
FMEException – An exception is raised if an error occurred.