Point in Polygon Calculations with the PointOnAreaOverlayer

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2016.x


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 has several transformers that will carry out this function, but the most commonly used one is the PointOnAreaOverlayer.




Source Data

There are three source datasets for this example: 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.

In the FME Data Inspector they look like this (above, properties; below, artworks):




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 linework 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 complicated slightly because there may be more than one piece of artwork on a single property and there are several ways of managing this.


Step-By-Step Instructions

1. Start FME Workbench and begin with an empty canvas. Select Readers > Add Reader from the menubar.

Set the data format to Esri Shapefile. Select the attached dataset as the source. This will read the Shapefile dataset that identifies city properties.

2. Again select Readers > Add Reader from the menubar. This time set the format to Autodesk AutoCAD DWG/DXF and select the attached DWG dataset as the source. Before clicking OK, open the parameters dialog and set Group Entities By to "Attribute Schema".

This will read the AutoCAD dataset that defines property boundaries.

3. Add an AreaBuilder transformer and connect the AutoCAD ParcelLines feature type to its input port. This will convert the property boundaries from lines into polygons.

4. Add a PointOnAreaOverlayer transformer. Connect the CityProperties feature type to its Point input port and the AreaBuilder:Area output port to its Area input port:



This will copy attributes from point features onto polygon features, where there is an overlap. To assess if that overlap has taken place, we need to check how many overlaps took place.

5. Add a Tester transformer to the workspace. Connect it to the PointOnAreaOverlayer:Area port:



Open the parameters dialog. Set up a condition to test for where _overlaps is greater than or equal to 1:



This will test the property boundary area features and filter out the ones that overlapped a point feature (and are therefore a city-owned property).

6. Once more select Readers > Add Reader from the menubar. This time set the format to Microsoft Excel and select the attached xlsx dataset as the source.

Before clicking OK, open the parameters dialog and check the preview. You should see there are several sheets in this dataset, and each includes a Longitude and Latitude column that FME identifies as X and Y coordinates:



Back in the main Add Reader dialog, select the Workflow Option "Single Merged Feature Type". This will ensure that all sheets are represented by a single object in the workspace.

7. Add a Reprojector transformer to the canvas and connect it to the newly added Excel feature type (labelled <All>):



This is necessary because the Excel values are in decimal degrees, while the rest of the data is in the UTM83-10 coordinate system. Open the Reprojector parameters dialog and set it up to reproject from LL83 to UTM83-10:



8. Now add a second PointOnAreaOverlayer. Connect Reprojector:Reprojected to the Point input port and Tester:Passed to the Area input port:



The previous 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, open the parameters dialog for the second PointOnAreaOverlayer. Under Attribute Accumulation check the boxed labelled "Generate List" and enter a list name such as "ArtList":



This will cause the artworks for a particular property to be saved as an FME list attribute called ArtList.


9. Add a second Tester transformer (or duplicate the first one) and connect it to the second PointOnAreaOverlayer's Area port. Again set it up to again test for _overlaps greater than or equal to 1.

Connect an Inspector transformer to this Tester's Passed output port and run the workspace.

The result will be a set of 42 polygons, each of which contains public art and has a list of those artworks attached:




10. 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 connected to the Passed port of the second Tester. Open the parameters dialog and under the List Attribute parameter select "ArtList" (or whatever you called the list in step 8).

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. Add a HTMLReportGenerator transformer connected to the ListExploder:Elements 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.

Firstly set the group-by parameter to "Property". This will create a separate report for each property.

Secondly, under Page Contents, the default content is a bar chart. Change this to Header and in the Content Settings under Text click the drop-down arrow and choose the Address attribute. Set the Header Level parameter to H3.




Now - underneath the Header - add a new Page Contents of type "List". For the settings choose the Title attribute under the List Item Content.

Click OK to close the dialog.

12. Finally select Writers > Add Writer from the menubar. Set the format to HTML and specify a file to write to. Click OK to add the Writer and connect its feature type to the Output port of the HTMLGenerator:




13. 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:



Was this article helpful?



Please sign in to leave a comment.