Creating Lists Using Transformers

Desiree Marsden
Desiree Marsden
  • 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 FME Data Inspector using feature caching. Note how some parks contain multiple point features. For example, if you zoom into Grimmett Park and then view the point features coming from the street trees data, it shows that Grimmett Park contains several trees in its boundary, as shown here in this annotated image of the Graphics View:

shwoing multiple points inside Grimmett.png

 

3. Set PointOnAreaOverlayer Parameters: Merge Attributes
Double-click the PointOnAreaOverlayer to open its parameters. By default, under Attribute Accumulation, Merge Attributes is unchecked, which means the area and point attributes will not be merged. Check Merge Attributes and change the Accumulation Mode to Merge Overlaid.

update1.png


Click OK to close the parameters.

 

4. Run the Workspace
Run the workspace and inspect Grimmett Park again, which contains the tree points. The PointOnAreaOverlayer adds an _overlaps attribute that counts the number of points in each area. In the Feature Information window, we can see that there are 16 _overlaps, but attributes from only one of the tree species have been added:

overlaping points on area for Grimmett.pngThis 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. Now, check Generate List on Output ‘Area’. Set the ‘Area’ List Name to _trees and set Add to ‘Area’ List to Selected Attributes.

Click the ellipsis next to Selected Attributes and select:

  • COMMON_NAME
  • DIAMETER
  • GENUS_NAME
  • SPECIES_NAME
  • TREE_ID
  • HEIGHT_RANGE

update2.pngClick OK to close the parameters.

 

6. Run the Workspace
Run the workspace and inspect Grimmett Park again. The Feature Information window shows a list attribute _trees{}, which contains information from tree points in the park for each of the attributes that were selected:
Grimace park as list attributes.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.