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:

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

  • Defaults to BOUNDED_CAST

kFME_ConvertInterpretation_numericToColor

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:

FMERaster

Returns:

The raster after converting the interpretation.

Raises:

FMEException – An exception is raised if an error occurred.