Remove Intersections From Line Networks

Ali Mokheamer
Ali Mokheamer
  • Updated

FME Version

Introduction

Occasionally it may be necessary to remove the intersections from a line network, possibly to optimize symbology for display. The LineJoiner transformer works well when the lines to be joined all share a unique identifier, but this is not always the case. In the case of a T intersection where all three lines share the same ID, the LineJoiner will choose which two lines to join randomly.
http_download_1444329908385_6032.png

This example workspace will join the two lines with the minimum angle between them, producing the most aesthetically pleasing result. If desired, attributes on the source data can be used to override the angle result.

 

Step-by-Step Instructions

Please download the attached template, RemoveIntersections.fmwt, open it in FME Workbench, and follow the article. The workspace contains numbered bookmarks matching each step described below.

1. Build a Network

1-Build-a-Network.png

NetworkTopologyCalculator: The workspace uses a NetworkTopologyCalculator to establish network IDs based on source data attributes - in this case, StreetName. The attributes chosen for the Group By in this transformer will override the angle when determining which lines to join. i.e., if the lines don't have the same value for StreetName regardless of the angle, then they aren't joined.

TopologyBuilder: The data is then sent to a TopologyBuilder transformer, which produces an arc/node topology where lines know which nodes connect them and nodes know the angle of the connecting lines. The TopologyBuilder is set to Group By the network ID established by the previous transformer to maintain any attribute override.

 

2. Process Nodes to Find Lines That Should Join

2-Process-nodes-to-find-lines-that-should-join.png

PythonCaller: The nodes are sent to a PythonCaller that uses an FMEObjects Python class to keep only the two links with the lowest divergence angle between them.

AttributeRenamer: The AttributeRenamers are used to renumber the arcs and links.

 

3. Cleanup Line Attributes and Geometry

3-Cleanup-line-attributes-and-geometry.png

StringConcatenator: Working with the line features, join the network ID to the edge ID to give each line segment a full identifier. This will be used in a final FeatureMerger to merge back the node information.

GeometryRemover: Also pass a copy of the line features through a GeometryRemover to remove the geometry. These features will be merged with the link data produced in Step 2 to identify arc numbers that can be joined.

AttributeKeeper: Keep only the edge and network ID values.

 

4. Merge Arc Links with Line Segments

4-Merge-arc-links-with-line-segments.png

FeatureMerger: The two links generated in Step 2 are merged back onto the line information, so each line knows its optimum preceding and succeeding link.

 

5. Analyze Arcs and Sort Them Into Order

5-Analyze-arcs-and-sort-them-into-order.png

Tester: Use Testers to remove unconnected lines and sort end lines from middle lines.

AttributeCreator: Set an attribute to be the sort order on the arcs.

Sorter: Sort the arcs so that the lines are sorted.

PythonCaller: Routine to establish a unique ID for each connected set of lines.

 

6. Final Merge and Line Join

6-Final-merge-and-line-join.png

FeatureMerger: Merge the calculated join ID onto each original line feature.

LineCombiner: The lines are then connected by a LineJoiner with the Group By set to the unique ID and the StreetName.

 

Result

http_download_1444329910351_6032.png

 

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?

Comments

0 comments

Please sign in to leave a comment.