Files
Introduction
In this exercise, you will learn how to simplify linear features by removing unnecessary coordinates using the Generalizer Transformer in FME.
Data Source
The source dataset is an Esri Shapefile containing bike paths in the City of Vancouver.
Step-by-step Instructions
In this scenario, you want to simplify a bike path network to show the general path rather than every single turn. We will use the Douglas (Generalize) algorithm to reduce the density of coordinates by removing vertices, thus simplifying the line.
To follow along with the tutorial please download the data from the Files section of the article.
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add an Esri Shapefile Reader
Add a 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, set the following:
- Format: Esri Shapefile
-
Dataset: BikePaths.shp
- Click on the ellipses to navigate to the file location on your computer
Click OK to finish adding the reader.
3. Generalize Lines
Click on the BikePaths reader feature type to select it. Then add a Generalizer transformer to the canvas by typing “Generalizer” to bring up the list of FME Transformers in the Quick Add Search. Select the Generalizer from the list of Transformers by double-clicking or using the arrow keys and Enter to add it.
Double-click on the Generalizer to open the parameters. In the parameters, confirm that the Algorithm is set to Douglas (Generalize), then set the Generalization Tolerance to 10.
We used the default Douglas algorithm because it removes vertices that cause a deviation below the Generalization Tolerance, while leaving the locations of the remaining vertices unchanged. This algorithm is good at reducing the number of points in a line; however, it is not very good at preserving the line's shape or spatial relationships relative to other entities. For more technical details, see the Generalizer Documentation.
4. Run Workspace
Connect an Inspector transformer to the Generalizer's Output port.
Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar.
After running the workspace, the output will be opened in Visual Preview. Viewing both of the datasets together (by adding a second Inspector to the reader feature type), you can see that the blue/teal line is the generalized line with fewer points than the original red line.
Another transformer to consider for thinning or smoothing data is the SherbendGeneralizer. This transformer is particularly useful for contour thinning and can preserve the spatial relationships among features. In other words, it ensures that thinned lines do not cross one another and also honors spot heights or their equivalents.
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.