Raster Slope Calculations as a RasterConvolver Example

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2018.x


FME already has transformers for directly calculating slopes from raster features; however, the RasterConvolver can be made to create the same result, and is a good example of raster DEM convolution.

Convolution is a mathematical operation carried out between a raster feature and a matrix of numbers (a kernel). The definition of operation and kernel is often called a filter.

This exercise is a good example of convolving a raster feature in multiple ways, and combining the results together to give the required solution.

Source Data

The source data for these examples is a Raster DEM dataset in CDED format. In the FME Data Inspector it looks like this:


The cell values represent elevation. The lighter the color, the higher the elevation. Darker areas represent low-lying areas.

Step-By-Step Instructions

1. Start FME Workbench and begin with an empty canvas. Select Readers > Add Reader from the menubar.

When prompted set the data format to Canadian Digital Elevation Data (CDED) (or U.S. Geological Survey Digital Elevation Model (USGSDEM) - the two are different names for the same format).

Select the attached data as the source dataset.

2. Place a RasterConvolver transformer on the canvas and draw a connection from the reader feature type to the transformer.

Open the parameters dialog. Select the Line Detection: Horizontal filter:



This filter identifies lines in an east-west (left-right) direction.

3. Place a second RasterConvolver transformer on the canvas and draw a second connection from the reader feature type to the transformer.


Open the parameters dialog and this time select the Line Detection: Vertical filter.

These two filters will identify slopes in a horizontal and vertical directions. Neither of the results is adequate in itself, but can be combined together to give the required result.

4. Place a RasterExpressionEvaluator transformer on the canvas and, without connecting to anything else, open up the parameters dialog.

Set the Mode parameter to Two Rasters:


In the Band Expression(s) field, set Interpretation to Preserve. In the Expression field enter:

@sqrt((A[0]*A[0]) + (B[0]*B[0]))

In other words we are combining the two raster features together. The new value for each cell will be the square root of Raster A's value (squared) plus Raster B's value (squared).


Now close the parameter dialog and connect the two RasterConvolver outputs to the A and B input ports on the RasterExpressionEvaluator:


5. Run the workspace, using either Cached Features or an Inspector transformer in order to inspect the output of the RasterExpressionEvalautor. The results will look like this:



Optional Steps

There are a number of optional steps we can take to confirm the result.

6. Because there is already a RasterSlopeCalculator transformer for FME, place one of those. Connect it as a third connection from the reader feature type:


Check the transformer parameters and set the Output Measurement parameter to "Percent Rise". Run that section of workspace and inspect the data to ensure it looks the same as the RasterConvolvers created.

7. The two results should look the same, but that doesn't mean they are identical. To check add a RasterStatisticsCalculator to both the RasterExpressionEvaluator and RasterSlopeCalculator transformers. Open the parameters dialogs and set up both transformers to record the minimum, maximum and mean values for band 0:



Re-run the workspace and inspect the two output raster features. Notice that the min, max, mean values are not the same. Therefore the datasets presumably have the same range of slopes, but not the exact same values. If we only cared about the image, then either result would be fine; if we cared about the actual values then we would probably prefer the RasterSlopeCalculator, whose values are known to be the slope percentage.

Was this article helpful?



Please sign in to leave a comment.