Files
Introduction
Perhaps the most well-known GIS operation is to identify whether a point object lies inside or outside of a given polygon. This is called a Point in Polygon operation.
For example, a user might have a dataset of points representing buildings that are for sale. The user also has a dataset of polygons representing planning restrictions, such as Conservation Zones, Smoke Control Areas, or Restrictive Covenants (agreements on how land can be developed). By carrying out a point in polygon operation they can determine which restrictions - if any - apply to a particular property.
FME Workbench has several transformers that will carry out this function, but the most commonly used one is the PointOnAreaOverlayer. In this article, you’ll discover how to utilize the PointOnAreaOverlayer transformer using a Shapefile, a DWG file, and an Excel sheet.
There are three source datasets for this example, all publicly available on the City of Vancouver’s Open Data Portal: a vector line dataset of parcel boundaries in AutoCAD DWG format; a vector point dataset (in Esri Shapefile) representing properties owned by the city; and a non-spatial dataset (an Excel spreadsheet with columns for latitude and longitude) representing public artworks. This data, as well as the workspace for this demo, can be downloaded from the Files section.
In FME Workbench Data Preview they look like this (above: properties; below: public art):
Video
This video was created with an older version of FME Workbench. The user interface may look different, but the techniques are the same.
Step-by-Step Instructions
The scenario for this example is that we wish to find out which artworks are located on which city properties. The workspace will turn the property lines into polygons, and the non-spatial artwork into point features. A point-in-polygon operation will identify which property polygons belong to the city, and a second point-in-polygon operation will identify which city properties contain public works of art.
A final operation is to write the data to an HTML report. This is slightly complicated because there may be more than one piece of artwork on a single property and there are several ways of managing this.
1. Start FME Workbench and Add City Properties Data
Start FME Workbench and click on New to open a blank workspace.
To add a source dataset, click the Reader button from the Toolbar. In the Add Reader dialog, enter the following:
- Format: Esri Shapefile
-
Dataset: /CityProperties.shp
- Click on the ellipsis (blank document icon for macOS) and browse to the dataset
Then click OK.
2. Add Parcel Data
Again, click the Reader in the Toolbar. In the AddReader dialog, enter the following:
- Format: Autodesk AutoCAD DWG/DXF
- Dataset: /Parcels.dwg
-
Parameters:
- Group Entities By: Attribute Schema
Click OK twice to add the reader to the workspace.
3. Add an AreaBuilder Transformer
Type AreaBuilder anywhere on the canvas, then hit Enter. Connect the AutoCAD ParcelLines feature type to the AreaBuilder Input port. This will convert the property boundaries from lines into polygons.
4. Add a PointOnAreaOverlayer Transformer
Click Transformer in the Toolbar, type PointOnAreaOverlayer, and double-click to add to your workspace.
Connect the CityProperties Shapefile feature type to the PointOnAreaOverlayer Point input port.
Connect the AreaBuilder Area output port to the PointOnAreaOverlayer Area input port:
Open the PointOnAreaOverlayer parameters dialog and set the following:
-
Attribute Accumulation:
- Merge Attributes: Enabled
This will copy attributes from point features onto polygon features, where there is an overlap. To assess if that overlap has taken place, we will use a Tester transformer.
5. Assess Overlaps with a Tester
Add a Tester transformer to the workspace. Connect the PointOnAreaOverlayer Area output port to the Tester Input port:
Double-click the Tester transformer to open the parameters dialog. Enter the following:
-
Left Value: _overlaps
- Click the drop-down arrow to select the Attribute Value
- Operator: >=
- Right Value: 1
Click OK to close the dialog.
This will test the property boundary area features and filter for the ones that overlapped a point feature (and are, therefore, a city-owned property).
6. Add the PublicArt Excel File
Select Reader from the Toolbar. Set the following parameters:
- Format: Microsoft Excel
- Dataset: /PublicArt.xlsx
- Single Merged Feature Type: Enabled
Before clicking OK, open the parameters dialog and check the preview. You should see that there are several sheets in this dataset, and each includes a Longitude and Latitude column that FME Workbench identifies as X and Y coordinates:
Click OK twice to add the reader to the canvas.
7. Reproject PublicArt Excel to UTM83-10
The PublicArt Excel values are in decimal degrees (LL83), while the rest of the data is in the UTM83-10 coordinate system. We will use the Reprojector transformer to reproject the data from LL83 to UTM83-10.
Add a Reprojector transformer to the canvas and connect the newly added PublicArt Excel feature type (labeled <All>) to the Reprojector Input port:
Open the Reprojector parameters dialog and set the following:
- Source Coordinate System: LL84
- Destination Coordinate System: UTM83-10
8. Add a Second PointOnAreaOverlayer
Add another PointOnAreaOverlayer transformer to your workspace. Connect the Reprojector Reprojected output port to the new PointOnAreaOverlayer (PointOnAreaOverlayer_2) Point input port:
The first PointOnAreaOverlayer was an overlap with only one result: a property either belongs to the city or it doesn't. However, the second PointOnAreaOverlayer can have multiple results, because there might be multiple artworks on a single site.
For that reason, we will create a list attribute to record multiple artworks on a single site. Open the parameters dialog for the second PointOnAreaOverlayer and enter the following:
-
Attribute Accumulation:
-
Generate List on Output ‘Area’: Enabled
- ‘Area’ List Name: _Art
- Add To ‘Area’ List: All Attributes
-
Generate List on Output ‘Area’: Enabled
This will result in all artworks for a particular property to be saved as an FME list attribute called _Art.
9. Test for Overlaps, Inspect, and Run Workspace
Add a second Tester transformer (or duplicate the first one). Connect the second PointOnAreaOverlayer Area output port to the second Tester (Tester_2) Input port. Open the second Tester dialog and set it to test for _overlaps greater than or equal to 1:
-
Left Value: _overlaps
- Click the drop-down arrow to select the Attribute Value
- Operator: >=
- Right Value: 1
Run the workspace by clicking the Run button in the Toolbar. To view the results, click the green data cache icon next to the Tester Passed output to inspect cached data.
If you do not see the cached data button, check your Run Workspace properties by clicking the drop-down next to Run in the Toolbar and ensuring Enable Data Caching is selected.
The result will be a set of 42 polygons, each of which contains public art and has a list of the artworks attached:
10. Use a ListExploder to Handle List Values
An FME "list" is a way to have multiple values for a single attribute. Unfortunately, this is not a structure that many formats support natively. Therefore, we need to handle these values in some way.
Add a ListExploder transformer to your workspace. Connect the second Tester Passed output port to the ListExploder Input port. Open the parameters dialog and enter the following:
- List Attribute: _Art{}
This is one way to handle a list. It "explodes" it from one feature with multiple values to multiple features, each with one value.
11. Create a Report from Results
Add an HTMLReportGenerator transformer and connect the ListExploder Elements output port to the HTMLReportGenerator Input port:
Open the parameters dialog. We'll set this up to create a report where each property is shown with a list of the artworks that belong to it. Enter the following:
-
Group Processing: Enabled
-
Group By: Property
- Click the ellipsis to select the Property attribute, which will create a separate report for each property
-
Group By: Property
We will add two content types to the page: a header and a list. To add and format the header, set the following parameters:
-
Page Contents:
- Drop-down: Header
-
Content Settings:
-
Text: Address
- Use the drop-down to select the attribute value
- Header Level: H3
-
Text: Address
Now we will add and format the list:
-
Page Contents:
-
Drop-down: List
- Click the blank cell under Header to pick from the drop-down menu
-
Drop-down: List
-
Content Settings:
- List Item Content: Title
Click OK to close the dialog.
This allows us to individually format elements on the HTML page.
12. Write Report to File
Finally, we will write the report to a file using a writer. Click Writer in the Toolbar and set the following parameters then add it to your workspace:
- Format: HTML
-
Dataset: HTML
- Specify a file name and location to write to
Connect the HTMLReportGenerator Output port to the Writer (labeled HTML) feature type:
13. Run Workspace and View Output
Re-run the workspace. Locate the HTML file that has been written and open it in a web browser. You will find it displays a list of properties, each with its own list of artworks:
Additional Resources
PointOnAreaOverlayer Transformer Documentation
Data Attribution
The data used here originates from data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.