Cleaning Geometry and Performing Spatial Joins

Kailin Opaleychuk
Kailin Opaleychuk
  • Updated

FME Version

  • FME 2021.0

Introduction

This example demonstrates how to use the SpatialRelator. Here, we are identifying spatial (topological) relationships between datasets near the Vancouver area. The first dataset (TRS.shp, available in SpatialRelator.zip), contains feature information that is also applicable to the second shapefile (ASLD.shp). The goal is to apply township and other attribute information to ASLD buildings that are spatially related to, or “within” TRS building ranges. Before doing this, we will clean the geometry to harmonize the datasets and increase feature accuracy. 
 

Step-by-step Instructions

1. Start Workbench
Open Workbench and start a new workspace.

2. Add a Shapefile Reader
We are going to read in a total of 2 shapefiles. The first shapefile we will read in is: ASLD.shp. Drag and drop the shapefile onto the canvas. A shapefile reader will open. Leave all parameters as default. 

1.jpg

3. Add another Shapefile Reader
We are going to repeat the process above, and add our second shapefile: TRS.shp. Leave all parameters as default once again.

2.jpg

4. Inspect your Data
Click Run, and inspect your cached data using the Visual Preview Window. 

3GOOD.jpg

5. Add an AnchoredSnapper
Add an AnchoredSnapper transformer to the canvas. Connect the ASLD feature type to the Candidate port on the AnchoredSnapper. This makes TRS our Anchor, connecting the corresponding feature types/ports. Set the snapping type to Segment Snapping, with a Snapping Distance of 0.1 and Tolerance as Automatic.

4_part1.jpg
4_part2.jpg

6. Add another AnchoredSnapper
Next, we are going to add a second AnchoredSnapper. Connect the output port from the Snapped and Untouched output ports to the Anchor input port. The TRS feature type is now the Candidate feature. All parameters will mirror from the step above (Set the snapping type to Segment Snapping, with a Snapping Distance of 0.1 and Tolerance as Automatic).

4.jpg

7. Add a SpatialRelator
Add a SpatialRelator to your workspace, connect the AnchoredSnapper_2 output from the Snapped and Untouched to Supplier, and Anchor to Requestor. Open the transformer parameters, select “Requestor is Within Supplier” as the Spatial Predicate to Test. Enable Generate List. Assign “TRS_relationships” as the List Name and select the following attributes: Range, Section, Township. Leave all other parameters as default. Click Ok and Run your workspace once again.

6.jpg

8. Add a ListExploder
Add a ListExploder and connect it to the SpatialRelator output. Set List Attribute to “TRS_relationships”. Leave all other parameters as default. Click Ok.

7.jpg

9. Add a Shapefile Writer
Add a Shapefile writer to the canvas. Select a Destination for your output and set Shapefile Definition to Automatic. Leave all other parameters as default. When prompted to Select Feature Type, select ASLD. Connect the Elements port to a newly added Shapefile writer feature type. Before running, open the writer parameters and rename your output (e.g. "ASLD_TRSRelations" or equivalent). Run your workspace.

8.jpg

Now, any ASLD features that are within TRS polygons have Township, Section and Range attributes associated which can now be leveraged. 

9.jpg
10.jpg

 

Data Attribution

The data in this article was created using open data made available by the City of Vancouver, British Columbia.
 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.