Exercise 3 Grounds Maintenance Project - Calculating Statistics
Data City Parks (MapInfo TAB)
Overall Goal Calculate the size and average size of each park in the city, to use in Grounds Maintenance estimates for grass cutting, hedge trimming, etc.
Demonstrates Content Transformation. Schema Mapping
Start Workspace C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex3-Begin.fmw
End Workspace C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex3-Complete.fmw

Let's continue your work on the grounds maintenance project.

In case you forgot, the team responsible for maintaining parks and other grassed areas needs to know the area and facilities of each park to plan their budget for the upcoming year.

In this part of the project, we’ll calculate the size and average size of each park, and ensure that information is correctly mapped to the destination schema.

1) Start Workbench
Start Workbench (if necessary) and open the workspace from Exercise 2. Alternatively you can open C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex3-Begin.fmw

2) Add an AreaCalculator Transformer
To measure the area of each park feature, an AreaCalculator transformer must be used. “Calculator” is the term for when FME computes new attribute values.

Click on the connection between Tester:Passed port and the writer feature type ParksMaintenanceData. Start typing the letters “areac”. You will see the Quick Add list of matching transformers appear beneath.

Select the transformer named AreaCalculator by double-clicking it:

3) Add a StatisticsCalculator Transformer
Using the same method, place a StatisticsCalculator transformer between the AreaCalculator:Output port and the ParksMaintenanceData feature type.

BUT! Do not click anything else yet! The transformer will now look like this:

By default, the Summary port has been connected, and we need the Complete port connected instead. But notice the little pop-up icons over the top. Click the right-hand icon (the one with the ? character). Doing so pops up a further list of ports:

Click on the Summary port entry to disconnect that, and then on the Complete port entry to connect that:

Notice how the connection has been changed from the incorrect Summary port to the correct Complete port.

These pop-up menus are a great help in schema mapping and other feature connections.

The latter part of the workspace now looks like this:

4) Check AreaCalculator Settings
Inspect the AreaCalculator parameters:

The default settings cause the calculated value to be placed into an attribute called _area. However, the ParksMaintenanceData schema requires an attribute called ParkArea, so change this parameter to create the correct attribute:

Once you click OK or Apply, notice that the attribute on the writer feature type is now flagged as connected.

5) Check StatisticsCalculator Settings
A red icon indicates the StatisticsCalculator has parameters that need to be defined.

Inspect the StatisticsCalculator transformer's parameters. The attribute to analyze is the one containing the calculated area; so select ParkArea:

Examine what the default setting is for an attribute name for average (mean) park size. Currently, it doesn't match the ParksMaintenanceData schema, which requires an attribute named AverageParkArea.

Change the attribute from _mean to AverageParkArea. For Best Practice reasons, delete/unset any StatisticsCalculator output attributes that aren't required (for example _range and _stdev).

6) Run the Workspace
Add another bookmark if you wish, run the workspace, and inspect the result of the translation using the FME Data Inspector:

The Table View window shows the area of each park and the average area of all parks.

7) Save the Workspace
Save the workspace – it will be completed in further examples.

Advanced Exercise
Notice that the numbers in the Table View show the results have been calculated to 12 decimal places. This is in excess of the precision that you require. As an advanced task - if you have time - use the AttributeRounder transformer to reduce the values to just 2 decimal places.

If you wish, you can also calculate the smallest, largest, and total park areas; but don't forget to add them to the writer schema if you want them to appear in the output.

By completing this exercise you have learned how to:
  • Carry out content transformation with transformers (AreaCalculator, StatisticsCalculator)
  • Manage transformer connections using pop-up buttons
  • Use transformer parameters to create attributes that match the writer schema

results matching ""

    No results matching ""