Files
Introduction
Typically, selecting by location is done through a graphical user interface such as ArcMap or QGIS. However, in FME, you can perform the same task by querying your data with a Tester to “select” the desired feature(s), then select the features that pass the query using the NeighborFinder.
Data Source
The first source is a feature class from the Community geodatabase and contains schools in the City of Vancouver.
The second source is an Esri Shapefile containing parcel polygons in the City of Vancouver.
Step-by-step Instructions
In this scenario, you will learn how to query the school's dataset in order to select parcel polygons within 200m of King George Secondary and Henry Hudson Elementary.
To follow along with this tutorial, please download the source files from the Files section of the article.
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add an Esri Geodatabase (File Geodb Open API) Reader
Add a 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, set the following:
- Format: Esri Geodatabase (File Geodb Open API)
-
Dataset: Community.gdb
- Click on the ellipses to navigate to the location of the file on your computer
Click OK to open the Select Feature Types window.
In the Select Feature Type dialog, select Schools, then click OK twice to finish adding the reader.
3. Add Parcels Esri Shapefile Reader
Next, add another reader to the canvas and set the following:
- Format: Esri Shapefile
-
Dataset: Parcels.shp
- Click on the ellipses to navigate to the location of the file on your computer
Click OK to add the reader to your canvas.
4. Filter Schools
Now we need to filter for the schools we are interested in. Click on the Schools reader feature type to select it. Then add a Tester to the canvas by typing “Tester” to bring up the list of FME Transformers in the Quick Add Search. Select the Tester from the list of Transformers by double-clicking or using the arrow keys and Enter to add it.
Double-click on the Tester to open the parameters. In the parameters, we need to set up an OR test for the two schools. Set the following test clauses:
-
Left Value: school_name
- Operator: Begins With
- Right Value: King George
- Logic: OR
-
Left Value: school_name
- Operator: Begins With
- Right Value: Henry
The parameters should look like the image below. Click OK to accept the parameters and add the transformer to the canvas.
5. Find Neighboring Parcels
Add a NeighborFinder to the canvas and connect the Candidate input port to the Tester Passed output port. Then connect the Base input port to the Parcels reader feature type. This will result in the connection lines crossing. To fix this, right-click on the Base port and select Move Down.
In the NeighborFinder parameters, set the Maximum Distance to 200. This value is in map units, but since our coordinate system is UTM83-10, the units are in meters.
6. Run Workspace
Connect an Inspector transformer to the MatchedBase output port on the NeighborFinder.
Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar.
After running the workspace, the polygons within a 200-meter radius of each school will be selected.
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.