Generate Contour Data from Raster

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

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 based on the input value of the raster cells, which are then used to generate contour lines.

previewoutput.gif

 

Step-by-step Instructions

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

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 on 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 on the Run button on the top toolbar, or by using Run > Run Workspace on the top menu bar. 
Run.png

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


 

 

Data Attribution

Data used in this tutorial 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?

Comments

0 comments

Please sign in to leave a comment.