Files
Introduction
Small polygons are polygons whose area is less than a specified tolerance. These can be identified by measuring polygon areas and then applying a test condition using a filter transformer.
Testing for small polygons is a good QA check because polygons below a certain size usually indicate problems such as overlaps, slivers, and misaligned linework.
It is also simple to count how many bad features exist. However, fixing polygons like this automatically is more difficult, as covered later in this article.
The first source dataset for this example is a set of lines, in an AutoCAD DWG dataset, representing the outlines of property boundaries in the City of Vancouver.
The second dataset, in Esri Geodatabase (File Geodb) format, is a set of point features that represent addresses.
With Feature Caching enabled, a subset of the datasets looks like this in Visual Preview:
The scenario in this article is to transform these lines into true polygon features. This is simple in FME, but this article adds QA checks to ensure that no undersized polygon features are created. An undersized polygon that contains an address point is a particular concern.
Step-by-Step Instructions
This article is divided into three parts: locating small polygons, counting them, and fixing them. Complete each part in order, using the same workspace.
Part 1: Locating Small Polygons
Follow these steps to learn how to identify small polygon features.
1. Open FME Workbench and Add Parcel Data
Open FME Workbench. On the top menu, click Add Reader. In the Add Reader dialog:
- Format: Autodesk AutoCAD DWG/DXF
-
Dataset: /Parcels.dwg
- Browse to downloaded dataset
-
Parameters:
- Group Entities By: Attribute Schema
Click OK to add the reader.
2. Create Polygons from Line Features
The source dataset consists of line features. Creating polygons requires a single FME transformer: AreaBuilder.
Add an AreaBuilder transformer and connect it to the ParcelLines feature type. Default parameters for this exercise are fine.
3. Measure the Area of the Small Polygons
To test for small polygons, first measure the area of each polygon. This is done with the AreaCalculator transformer.
Add an AreaCalculator transformer and connect it to the AreaBuilder Area output port. Default parameters for this exercise are fine.
4. Add Address Point Data
In most cases, a filter transformer would be added next to test the area. This example adds an extra level of detail: address points.
Add another reader. In the Add Reader dialog:
- Format: Esri Geodatabase (File Geodb)
-
Dataset: /Addresses.gdb
- Browse to downloaded dataset
When prompted, select only the PostalAddress table to add to the workspace. The PostcodeBoundaries table is not required.
5. Overlay Address Point Attributes onto Polygons
To transfer address point attributes onto the polygons, use a PointOnAreaOverlayer transformer.
Add a PointOnAreaOverlayer transformer. Connect the PostalAddress feature type to the PointOnAreaOverlayer Point input port, and connect the AreaCalculator Output port to the PointOnAreaOverlayer Area input port.
Run the workspace and inspect the PointOnAreaOverlayer Area output port by clicking the green inspect button. The result is a set of polygon features with an attribute for the polygon area (_area) and, if the polygon overlaps an address point, attributes defining the address.
6. Filter Out Bad Features
Filter the bad features. Vancouver building regulations state:
The floor area of a micro dwelling must be at least 29.7m2
We're looking at land parcel boundaries, not building footprints, but still, 30m2 seems a good cutoff point below which a polygon is likely to be erroneous.
We want to test for three scenarios:
- Polygons of the correct size
- Polygons of an incorrect size
- Polygons of an incorrect size containing an address point
The best way to test multiple conditions like this is with a TestFilter transformer.
Add a TestFilter transformer connected to the PointOnAreaOverlayer Area output port.
Open the TestFilter parameters dialog. Double-click the first row under the Test Condition column to open the condition editor. Set the following:
- Test Condition 1
- Clause 1:
- Left Value:
_area - Operator: <=
- Right Value: 30
- Left Value:
- Clause 2:
- Logic: AND
- Left Value:
_overlaps - Operator: >=
- Right Value: 1
- Output Port: Small with Address Point
- Clause 1:
Click OK to return to the previous dialog.
Double-click the test condition for the Else If row and set it to:
- Test Clauses:
- Left Value:
_area - Operator: <=
- Right Value: 30
- Left Value:
- Output Port: Small without Address Point
Click OK.
- Else:
- Output Port: Correct Size
Click OK to return to the canvas.
7. Run the Workspace and Inspect the Output
Run the workspace. The result is three outputs that represent the three different states. Inspect the features flagged as small to confirm that they are incorrect. Most are polygons where the lines of two boundaries have crossed, creating a small sliver polygon.
Part 2: Counting Small Polygons
Counting the number of bad features is straightforward because they are already filtered. For example, the FME Form feature counts show the numbers involved.
Creating a count stored in an attribute uses the StatisticsCalculator transformer.
Follow these steps to learn how to count small polygon features.
8. Add a StatisticsCalculator
Add a StatisticsCalculator transformer and connect it to the first TestFilter output port. Open the StatisticsCalculator parameters dialog and set the following:
-
Statistics to Calculate:
- Attribute: _area
- Total Count: Enabled
The selected attribute does not matter, since only the count of features is needed. Click OK to close the dialog.
9. Duplicate the Existing StatisticsCalculator
Select the StatisticsCalculator and press Ctrl+D. Connect the duplicate to the second TestFilter output port. Because this is a duplicate, there is no need to edit the parameters.
10. Re-Run the Workspace
This time, the output includes an attribute indicating how many bad features there are for each type.
Part 3: Fixing Small Polygons
Fixing small polygons is not a simple task. Deleting the small polygons could create gaps in the topological coverage, and not all of them share a common ID number that would allow them to be merged (dissolved).
However, some solutions can be applied:
a) Delete the small polygons, then apply the SliverRemover transformer to the remaining data to fill any gaps.
b) Choose a feature neighboring a small polygon and dissolve the two together.
Follow these steps to learn how to fix small polygon features using the NeighborFinder and Dissolver transformers.
11. Delete the Two StatisticsCalculators
If no StatisticsCalculators were added, skip this step.
12. Add a Counter Transformer
Add a Counter transformer and connect it to the TestFilter Correct Size port. This creates a unique ID for each correctly sized polygon.
13. Add a NeighborFinder Transformer
Add a NeighborFinder transformer. Connect the small polygon features (the other two ports from the TestFilter) to the NeighborFinder Base port, and connect the Counter Output port to the NeighborFinder Candidate port.
Open the NeighborFinder parameters and expand Attribute Accumulation
- Merge Attributes: Enabled
14. Add a Dissolver Transformer
Add a Dissolver transformer. Connect it to the NeighborFinder MatchedBase port, and create a second connection from the Counter Output port to the Dissolver.
Open the Dissolver parameters dialog and set the following:
- Group Processing: Enabled
- Group By Attribute: _count
This causes small polygons to be dissolved into their neighbor.
15. Run the Workspace and Inspect the Dissolver Output
Most of the small polygons are fixed by being dissolved into their neighbor:
Add a final AreaCalculator transformer to help confirm this, if visual inspection of the data is not preferred.
Additional Resources
- Area Measurements with the AreaCalculator [Article]
- Data QA: Identifying Sliver Overlaps and Gaps in Polygon Coverage [Article]
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.