Files
Introduction
When assessing spatial relationships, a common scenario is determining whether one feature is within X distance of another; for example, is there a fire station/hall within 5km of a planned fireworks factory?
FME has several transformers that assess spatial relationships when features physically overlap (inside, outside, intersect, match, etc.), but no specific transformer to find relationships within a given distance.
Therefore, the solution is to create a buffer of X distance around one of the features, then perform a standard spatial overlay of the two datasets.
Video
The video was filmed using an older version of FME. The concepts are the same, but the interface may appear different.
Source Data
The first source dataset for this example is a set of lines (in a SpatiaLite database) representing roads designated as snow removal routes; i.e., roads with parking restrictions during winter so that snow can be cleared more efficiently. The second dataset (in GML format) is a set of point features that represent addresses.
Step-By-Step Instructions
The scenario is that these properties are for sale, and as members of the municipal GIS team, we have to tell prospective buyers whether a property is within 25 meters of a snow removal route.
To follow along with the tutorial, download the data from the article's Files section.
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add a SpatiaLite 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: SpatiaLite
-
Dataset: SnowRemoval.s3
- Click on the ellipses to navigate to the location of the file on your computer
Click OK to finish adding the reader.
3. Add a GML Reader
Add another reader to the canvas. Set the following:
- Format: OGC GML (Geography Markup Language)
-
Dataset: HouseInquiries.gml
- Click on the ellipses to navigate to the location of the file on your computer
Click OK.
4. Create a Buffer
Click on the snowremovalroute reader feature type to select it. Then add a Bufferer transformer to the canvas by typing “Bufferer” to bring up the list of FME Transformers in the Quick Add Search. Select the Bufferer from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it.
Double-click on the Bufferer to open the parameters. In the parameters, set:
- Buffer Distance: 25
- Buffer Distance Units: Meters
Click OK to accept the parameters.
5. Create Spatial Filter
Next, add a SpatialFilter to the canvas and connect the Filter input port to the Bufferer Buffered output port, and then connect the Candidate input port to the HouseInquiries reader feature type.
In the SpatialFilter parameters, click on the ellipsis next to Spatial Predicates to Test, uncheck any of the selected options, then select Filter OGC-Contains Candidate. This will now assess whether each candidate (property address) is contained by the buffered area of a snow removal route.
6. Run Workspace
Connect an Inspector transformer to the SpatialFilter Passed output port. Optionally, connect Inspectors to the Bufferer and the HouseInquiries reader feature type.
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, in Visual Preview, you can see that the procedure has successfully picked out which addresses are (and which are not) within 25 meters of a snow removal route.
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.