Data QA: Identifying Features Closer than a Minimum Distance

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

Features that are going to be used for cartographic production at a specific scale need to be a set distance apart in order to not overlap in the final map output. Testing for features closer than a set distance apart is therefore a useful ability in that scenario.

For example, here a user is mapping water fountains, but finds that - at the required scale - the chosen symbol overlaps with a building footprint:

qa-closefeatures-1.png

The user will need to therefore identify these features, quantify the problem, and then fix the issue by displacing the features to the required distance.

 

Source Data

The source datasets for this tutorial are a set of lines (in an AutoCAD DWG dataset) representing roads in the city of Vancouver, and a set of point features (stored in an Excel spreadsheet) representing public art:

qa-closefeatures-2.png

The scenario here is that we wish to create a map of the public artwork in the city of Vancouver. However, to ensure that no features overlap, we need to identify and move the public art features that are within 10 metres of the roads.

To do so we'll first use the NeighborFinder transformer (to identify bad features), the StatisticsCalculator (to count them), and then the Displacer transformer (to fix them).

 

Step-by-Step Instructions

Part 1: Identifying Invalid Feature

Follow these steps to learn how to identify features that fall within the minimum distance.
 

1. Start FME Workbench and begin with an empty canvas

Select Readers > Add Reader from the menubar.

Set the data format to Autodesk AutoCAD DWG/DXF. Select the attached dwg file as the source dataset. Click the Parameters button and set Group Entities By to "Attribute Schema".

Back on the main dialog, select the Workflow Option "Single Merged Feature Type". This will create a single FME feature type in Workbench. Click OK to add the reader.
 

2. Select Readers > Add Reader from the menubar for a second time

Set the data format to Microsoft Excel and select the attached xlsx file as the source dataset. Click the Parameters button. Ensure that the attributes "Longitude" and "Latitude" are defined with the data type x_coordinate and y_coordinate.

Back on the main dialog ensure the Workflow Option is still set to "Single Merged Feature Type" and click OK to add the reader.
 

3. Reproject the Excel dataset
The coordinates stored in the Excel dataset are in a Latitude/Longitude coordinate system, which is different to the coordinate system of the roads data (UTM83-10). To carry out this operation requires all data to be in a common coordinate system.

So, add a Reprojector transformer and connect the Excel reader feature type to its input port:

qa-closefeatures-3.png
 

4. Set the Reprojector parameters
Open the Reprojector's parameters dialog. Set it up to reproject the Excel data from LL83 to UTM83-10:

qa-closefeatures-4.png

Click OK to close the dialog.
 

5. Add a NeighborFinder transformer
Now we are ready to work on the data. To identify invalid features so that, perhaps, we can deal with them manually elsewhere, we'll use the NeighborFinder transformer.

Place a NeighborFinder transformer. Connect the Reprojector:Reprojected port to the NeighborFinder:Base input port. Connect the Roads feature type to the NeighborFinder:Candidate port:

qa-closefeatures-5.png
 

Open the NeighborFinder parameters dialog. Set the Maximum Distance parameter to 10.
 

6. Run the workspace and inspect the output

Features emerging from the MatchedBase port are within 10 metres of a road and therefore need attention.

 

Part 2: Counting Invalid Features

Counting the number of bad features is quite easy because we have already filtered them out. For example, even the Workbench feature counts show us the numbers involved:

qa-closefeatures-6.png

But to create a count stored in an attribute is just as simple using the StatisticsCalculator transformer.

Follow these steps to learn how to count short line features.
 

7. Add a StatisticsCalculator
Connect it to the NeighborFinder MatchedBase output port and open the parameters dialog.

First select fme_feature_type as the Attribute. In truth it doesn't really matter which attribute we select, since we only want a count of features.

Click the Total Count parameter so that a checkbox appears. That will provide a count of the bad features. Click OK to close the dialog.

Re-run the workspace. This time the output should include an attribute that denotes how many bad features there are of each type.
 

8. Calculating count based on neighborhood
If you inspected the original Excel dataset, you might have noticed the artwork for each neighborhood of Vancouver was in a separate sheet. If you want a count of the bad features based on the neighborhood, re-open the StatisticsCalculator parameters dialog and set the Group By parameter to group by the attribute fme_feature_type.
2021-12-15_13-29-13.png
 

Run the workspace and you will see the number of bad features for Downtown (16), Fairview (2), Mount Pleasant (1), Strathcona (3).

 

Part 3: Fixing Invalid Features

Features that are too close together can - depending on their geometry - be fixed quite easily using the Displacer transformer in FME. Carry out the following steps to complete the workspace and fix the invalid features automatically.
 

9. Delete the NeighborFinder transformer and add a Displacer transformer to the canvas
The Displacer can both locate and fix invalid features, so the NeighborFinder is no longer required.

Connect the Displacer to the roads and public art features - but this time the Roads are the Base features and the artwork supplies the Candidates:

qa-closefeatures-7.png

 

10. Set the Displacer parameters dialog
Set the Stiffness parameter to 1 and the Minimum Separating Distance to 10. This will ensure the points are at least 10 metres from the road.

Set the Base Type parameter to Multiple Bases (since there are multiple road features)

qa-closefeatures-8.png
 

11. Re-run the workspace and inspect the output
Notice that the artwork that was too close to a road has been moved away from it.

 

Notes

1 - The Displacer transformer works best with simple geometry such as point features. Trying to displace lines features is a more difficult task.

2 - Sometimes the Displacer results won't be perfect anyway. Find the Marinaside Crescent Lookout artwork and you will see that, although it was successfully moved away from one road, it is now too close to another!

 

qa-closefeatures-9.png

A feature that is sandwiched between two others like that has little chance of being fixed automatically.
 

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.