Line in Polygon

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2022.0

Introduction

In this exercise, you will use the SpatialFilter to set a spatial predicate that will determine which line features intersect polygon features. The SpatialFilter compares two sets of features to see if their spatial relationships meet selected test conditions. The features being tested (Candidate features) are identified as having Passed or Failed the test. For example, if you have a roads dataset (lines), and wanted to extract all the roads that passed through parks (polygons), you would direct the roads into the Candidate input port, and the parks into the Filter input port.

 

Step-by-step Instructions

In this scenario, you will merge MountPleasantClipBoundary polygon features with linear Street features and join attributes based on the spatial predicate, “Filter Intersect Candidate”. In this case, the Neighborhoods dataset is the filter because you want to extract all of the Streets that intersect the MountPleasantClipBoundary and merge the attributes of both features.

Sources
The first source dataset is an Esri Shapefile containing the Mount Pleasant neighborhood boundary in the City of Vancouver. 
MountPleasantClipSource.png

The second source dataset is an Esri Shapefile containing all of the roads in the City of Vancouver. 
RoadsSource.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 MountPleasantClipBoundary.shp dataset which is available for download from the Files section on this article. Then click OK to finish adding the reader.
 Boundary.png
 
3. Add Another Esri Shapefile Reader
Add another  Esri Shapefile reader to the canvas. Browse to the Roads.shp dataset, then click OK to finish adding the reader.
Roads.png
 
4. Filter Spatially 
To filter the data spatially, we will use a SpatialFilter transformer. Click on the MountPleasantBoundaryClip reader feature type to select it. Then add a SpatialFilter 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 MountPleasantBoundaryClip reader feature type will be automatically connected to the Base input port on the SpatialFilter. Connect the Roads reader feature type to the Candidate input port on the SpatialFilter. 
Connection.png
 
Double-click on the SpatialFilter to open the parameters. For this example, we can accept the default values, but note that we are using Filter OGC - Intersects Candidate as the Spatial Predicate to Test, as well we are merging the attributes. 
SpatialFilter.png

5. Run Workspace
Connect an Inspector transformer to the Passed output port on the SpatialFilter. 
Inspector.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, only the roads that are within/interset the MountPleasantBoundaryClip dataset will be available, and the two datasets will have their attributes merged. 
Output.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.