Generate Contour Data from Raster

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

In this tutorial, you will learn how to create contour lines using the ContourGenerator and a Digital Elevation Model (DEM). The ContourGenerator in FME constructs a Delaunay triangulation from the raster cells' input values, which are then used to generate contour lines.

previewoutput.gif

Step-by-step Instructions

In this scenario, you will create contour lines from the DEM because you want to create a 50m contour dataset for later use.

Data Source

The source dataset is a digital elevation model of the mountains north of Vancouver, British Columbia. 

1. Create a New Workspace

Open FME Workbench and create a blank workspace. 

NewWorkspace.png

2. Add a CDED Reader

Add a CDED (Canadian Digital Elevation Data) reader to the canvas by clicking on the Reader button on the top menu bar or by going to Readers > Add Reader. In the Add Reader dialog, select  CDED as the Format, then for Dataset, browse to the DEM-Full.dem dataset, which is available for download from the Files section of this article. Then click OK to finish adding the reader.

Reader.png

3. Create Contours

Click on the CDED reader feature type to select it.  Then add a ContourGenerator transformer to the canvas by typing “ContourGenerator” to bring up the list of FME Transformers in the Quick Add Search. Select the ContourGenerator from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it. Ensure that the reader feature type is connected to the Points/Lines input port. 

QuickAdd.png

Connection.png

Double-click on the ContourGenerator to open the parameters. In the parameters, set the Surface Tolerance to 0, then set the Output Contour Internal to 50. Surface Tolerance is a parameter used to filter vertices; however, since you are working with a raster dataset, you can turn this feature off by specifying a value of 0.

ContourGenerator.png

4. Combine Contour Line Segments

Next, we need to combine the contour line segments. Add a LineCombiner to the canvas and connect it to the Contours output port on the ContourGenerator. 

LineCombineConnect.png

In the parameters, set Combine On Attributes to _elevation, then click OK. 

LineCombiner.png

Note: In order for lines to be combined, they must meet at the exact same start/end point. Additionally, lines will remain broken at points where three or more lines converge. For more information, see the LineCombiner Documentation.

5. Run Workspace

Connect an Inspector transformer to the LineCombiner Combined output port. 

Workspace.png

Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar. 

Run.png

After running the workspace, the output will show contour lines 50 meters apart. 

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.