Creating Lists Using Transformers

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

Many FME transformers have a Generate List checkbox under the Attribute Accumulation section of their parameters dialog. For example:
dialog.png

For query transformers that can return multiple results, like the PointOnAreaOverlayer, these parameters can be used to generate a list to store the results.

In this scenario, we want to create park polygons that have attributes telling us what trees exist in each park. To do this, we will merge tree points with park polygons using the PointOnAreaOverlayer. However, it isn't enough to simply copy attributes from each tree to their respective park polygons, because what if there is more than one tree per park? List attributes are perfect for this scenario: if more than one tree falls within the same park polygon, we can use a list attribute to store information for all trees. The PointOnAreaOverlayer allows us to generate a list that stores the values for all points overlaid on the area.

The workspace will:

  • Read point data with information about trees.
  • Read polygon data with information about Vancouver parks.
  • Overlay the points and polygons using the PointOnAreaOverlayer.
  • Use list attributes to store the values of all tree points within each park.

 

Step-by-Step Instructions

Download the workspace template (park_trees_begin.fmwt) attached to this tutorial to work through the steps. A more advanced workspace that includes transformers for analyzing the results is included in the next article.

1. Open park_trees_begin.fmwt
Open the starting workspace template in FME Workbench. 

2. Run the Workspace and Inspect the Data
Run the workspace and view the data in Visual Preview or the Data Inspector using feature caching. Note how some parks contain multiple point features. For example, Grimmett Park contains several trees in its boundary, as shown in the graphics view:
image.png


3. Set PointOnAreaOverlayer Parameters: Merge Attributes
Double-click the PointOnAreaOverlayer to open its parameters. By default, the checkboxes under Attribute Accumulation are unchecked, which means the area and point attributes are not being merged and no list attributes are being created. Check Merge Attributes.
dialog.png

Click OK to close the parameters.

4. Run the Workspace
Run the workspace and inspect Grimmett Park again, which contains a few tree points. The PointOnAreaOverlayer adds an _overlaps attribute that counts the number of points in each area. In the Feature Information pane, we can see that it has sixteen overlaps, but attributes from only one of the tree species have been added:
image.png

This is the result of merging the incoming features. To include all trees in a given park, we need to create a list attribute.

5. Set PointOnAreaOverlayer Parameters: Generate List On Output 'Area'
Open the PointOnAreaOverlayer parameters again and uncheck Merge Attributes. Instead, check Generate List on Output ‘Area’ . Name the list _trees and use Selected Attributes to select the attributes: COMMON_NAME DIAMETER GENUS_NAME SPECIES_NAME TREE_ID HEIGHT_RANGE.
dialog.png

Click OK to close the parameters.

6. Run the Workspace
Run the workspace and inspect Grimmett Park again. The Feature Information pane shows a list attribute, _trees{}, which contains information from both tree points in the park:
image.png

We successfully used the PointOnAreaOverlayer to create a list called _trees{}, which stores the values of multiple tree points that fall within each park polygon. Note how each numbered list element contains the same set of attributes: COMMON_NAME, DIAMETER, etc.

The attached file park_trees_final.fmwt shows the final configuration of the PointOnAreaOverlayer.
 

Next Steps

The next step is to process and analyze the data. For example, a TestFilter can be used to filter out parks that contain no tree points, and then list manipulation transformers can be used for tasks like the following:

Count the number of trees in each park ListElementCounter
Find the maximum tree diameter ListSorter & ListIndexer
Find the count of each species ListHistogrammer
Create a list of species ListConcatentor
Find which parks have an Oak tree ListSearcher
Create a table of Park Trees with park name ListExploder
Find the average tree height in a park ListSummer
Find the Min/Max of tree diameters ListRangeExtractor


To learn about these list transformers, see the next article in this tutorial series, Transformers for Working with List Attributes.
 

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.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.