Correcting Topological Errors

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

In order to correct topology errors, you should first test to which features break the appropriate topology rule for your dataset. In this article, you will learn how to use FME to identify topological errors using the SpatialFilter. To see more data validation scenarios, check out the Tutorial: Data Validation and QA with FME tutorial.

 

Step-by-step Instructions

Exercise 1: Testing for Topology Errors on Linear Features

In this exercise, you will test for topological errors in a linear dataset. You are testing your dataset because you want to ensure the dataset was digitized correctly and bike path segments are snapped together.

Source
The source dataset for both exercises is an Esri Shapefile of bike paths in the City of Vancouver that has been modified to include topology errors. 
BikeTopoSource.png
 
1. Create a New Workspace
Open FME Workbench and create a blank workspace. 
NewWorkspace.png
 
2. Add an Esri Shapefile Reader
Add an Esri Shapefile 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 Esri Shapefile as the Format, then for Dataset browse to the BikePathTopology.shp dataset which is available for download from the Files section on this article. Then click OK to finish adding the reader.
Shapefi.png
 
3. Filter Features 
Click on the BikePathTopology reader feature type to select it.  Then add a SpatialFilter transformer to the canvas by typing “SpatialFilter” to bring up the list of FME Transformers in the Quick Add Search. Select the SpatialFilter from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it. 
QuickAdd.png

The BikePathTopology reader feature type will automatically be connected to the Filter input port on the SpatialFilter. We also need to connect the reader feature type to the Candidate input port, so we are comparing the features to themselves. Click and drag a connection line from the BikePathTopology reader feature type to the Candidate input port on the SpatialFilter. 
SFConnection.png
 
Double-click on the SpatialFilter to open the parameters. In the parameters, click on the ellipsis next to Spatial Predicate to Test. Select Filter OGC-Touches Candidate as the Test, then deselect any other tests. Click OK. Then uncheck Merge Attributes. 
SpatialFilter.png
 
4. Run Workspace
Connect an Inspector transformer to the Passed output port on the SpatialFilter, then connect another Inspector to the Failed output port. The one connected to the Passed output port will be all of the bike paths that touch, and the failed output port will be the features that are disjoint.  
Inspectors.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 be opened in Visual Preview. In Visual Preview, there will be 12 bike paths that are disjoint and not topologically correct. In the screenshot below, these are the paths in green. We will continue in this workspace in Exercise 2 to resolve these topological errors. 
VP1.png
 

Exercise 2: Correcting Topology Errors

In exercise 1, we tested for topological errors in a linear dataset by checking for disjoint lines. In this exercise, we will be correcting the disjoint features (identified by the <missing> predicate attribute) using the Snapper transformer. The goal of this exercise is to eliminate errors that were introduced by not snapping line segments to vertices/endpoints.
 
5. Disable SpatialFilter
Since we know what we need to fix, we can disable the SpatialFilter and the connecting Inspectors. A quick way to do this is by adding a bookmark around the SpatialFilters and Inspectors, by clicking and dragging a box around the objects, and selecting ctrl-B or cmd-B on your keyboard. Bookmarks can also be added by right-clicking on the canvas and selecting Create Bookmark. Name this bookmark Topology Inspector. After the bookmark has been added, right-click on it and select Disable All Objects in Bookmark. 
Disable.png

With the objects disabled, move the bookmark out of the way. 
Disabled.png

6. Add a Snapper
Since the SpatialFilter is testing for touching bike path segments, we want to correct the segments that are failing this test.  Add a Snapper to the canvas and connect it to the BikePathTopology reader feature type. 
Snapper.png
 
Open the Snapper parameters, then set the Snapping Type to Vertex Snapping. Next, set the Snapping Distance to 20. The Snapping Distance is measured in map units, which for this dataset is meters. 
SnapperParam.png
 
7. Recheck Topology
At this point, now that the features are fixed with the snapper, we could write the data out using a FeatureWriter. You can do this step if you wish, but for demonstration purposes, let’s use a Junction transformer to take the place of the FeatureWriter. Add a Junction to the canvas and connect both the Snapped and Untouched output ports from the Snapper. 
Next, duplicate the previous SpatialFilter and the two connected Inspectors (ctrl+D). Then connect both the Filter and Candidate input ports from the SpatialFilter_2 to the Junction output port. We could have skipped the junction and connected the input and outport ports directly, but we would have had multiple crossing lines. 
Workspace2.png
 
8. Run Workspace
Run the workspace and notice that there are no disjoint features from the SpatialFilter_2; this indicates that the topology was corrected.
VP2.png
 
If we enable the Topology Inspector bookmark and rerun the workspace, we can see exactly where the topology was corrected. In the screenshot below, the brown thick line is the corrected topology, and the blue line is the topology with errors. 
vp3.png
 

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.