|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|
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 in order 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:\FMEData2017\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 onto 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). This 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:
|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
View the AreaCalculator parameters in the Parameter Editor window by clicking on it in the canvas (alternatively click its cogwheel icon to open the parameters dialog). It will look like this:
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 the Apply button, 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.
View the StatisticsCalculator transformer's parameters. Again you may use either the Parameter Editor window or the transformer's own Parameters dialog.
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).
Finally, click Apply/OK to accept the changes.
6) Run the Workspace
Run the workspace.
Inspect the result of the translation using the FME Data Inspector.
Inspect the Table View window to discover 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.
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: