Sample and Demos

Simple Examples Using the RasterExpressionEvaluator Transformer

Article Number: 000001618 - Last Modified: Nov 9, 2011

RasterExpressionEvaluator is a transformer that evaluates expressions on each cell in a raster, such as algebraic operations or conditional statements.


The RasterExpressionEvaluator is a transformer that evaluates expressions on each cell in a raster, such as algebraic operations or conditional statements.

Simple Calculation Examples

Inverting Colors

This example demonstrates how to invert images with the following band interpretation list and expression:


User-added image    

User-added image
The images show Heritage Mountain Elementary School and the surrounding area in Google Earth
  • See RGBColorInverter.fmwt in the attached zip file

Brightness Correction

If an image is too dark, we can boost brightness with the following simple expression:


User-added image   

User-added image
Port Moody, Greater Vancouver

Note that this method should be used cautiously - if there are bright areas in the image, they will reach or exceed the maximum value (255 in my example), which will make them purely white (255, 255, 255 in case of RGB24), and the information in those areas will be lost.
  • See BrightnessCorrection.fmwt in the attached zip file

Color Correction

User-added image

If one of the colors on an image seems to dominate over the others, we can change only one band (or apply different coefficients to different bands):

User-added image
  • See ColorCorrection.fmwt in the attached zip file

Color to Grayscale Conversion

Most internet sources suggest the following formula for color to grayscale conversion (and many sources also mention that depending on the image it may vary):

0.2989*A[0] + 0.5870*A[1] + 0.1140*A[2]

User-added image   

User-added image

The workspace also makes an image based on calculating average values,
0.3333*A[0] + 0.3333*A[1] + 0.3333*A[2]

but the first formula gives better contrast.
  • See RGB2Grayscale.fmwt in the attached zip file

Unit Conversion

Conversion between all kinds of units is a very natural operation for RasterExpressionEvaluator. In this example we take a numeric raster representing a DEM in meters and convert the units into feet (band interpretation is INT32):

If we inspect results in Visualizer, we will see the results of the conversion:
User-added image   

User-added image
  • See UnitConversion.fmwt in the attached zip file


Suggested Similar Articles

Introduction into Minecraft world making with FME 2015

These examples demonstrate how to use conditions in the RasterExpressionEvaluator to isolation and perform operations on specific band values in a raster.

Several examples of how the RasterInterpretationCoercer can help you optimize your raster data for display or further processing.

Learn how to apply color to point clouds from a raster images and manipulate the color values to highlight features.

Replaces the geometry of input raster features with a polygon covering the extents of the raster. In this example, it is used to support vectorization of an input DEM into classified elevation vector polygons.