|Exercise 1||Applying the Style Guide|
|Data||Addresses (Esri Geodatabase)
Crime Data (CSV - Comma Separated Value)
Parks (MapInfo TAB)
|Overall Goal||Work on Vancouver Walkability Project|
|Demonstrates||Style Best Practice|
You have just been assigned to a project to calculate the "walkability" of each address in the city of Vancouver. Walkability is a measure of how easy it is to access local facilities on foot. It will include a measure of the distance to the nearest park, the amount of crime in an area, and other similar metrics.
The workspace for this project has already been started, with crime information being connected to each address, but the author was unaware of the FME style guide, so as well as continuing the project, a certain amount of styling must be added to the existing content.
1) Start Workbench
Start FME Workbench.
Notice that the workspace file is a template (it has the file extension .fmwt). That is good because it means that there might be existing caches for the project. Ensure that Run with Feature Caching is turned on and open the workspace template from C:\FMEData2018\Workspaces\DesktopBasic\BestPractice-Ex1-Begin.fmwt.
This workspace needs some style applied to it in the form of bookmarks and annotation.
2) Rearrange Transformers
Firstly the Inspector transformer is not required - we can inspect caches more easily - and can be deleted. However, because it has two connections into it, and we want to keep track of what they are, once deleted, replace it with a Junction transformer.
Then clean up the transformers around it so that there are no overlapping connections:
Now rearrange the first part of the workspace, avoiding overlapping connections and looking out for transformers that might logically be grouped in a bookmark:
3) Add Style
Having rearranged the transformers, now add bookmarks and annotation where appropriate. This step will require some inspection of the transformers to see what each of them is doing. But you should be able to see at least two groups of transformers that can be placed into a bookmark:
Don't forget to phrase annotation and bookmark titles so that future users of the workspace will be able to tell at a glance what the workspace is supposed to do.
Overlapping connections can also be cleaned up by rearranging the order of transformer output ports:
4) Run Workspace
If you wish, run the workspace by using Run to This on the newly placed Junction transformer. You should then be able to click on the Junction and press Ctrl+I to inspect the data at that stage of the translation.
One thing to notice is that the CSV (crime) reader is reading data directly from an Excel spreadsheet on the City of Vancouver website. For this reason it's important that we retained the cached data and do not have to read it all over again.
5) Add Parks Data
Now let's continue the project by handling some parks data. Add a reader with the following parameters:
|Reader Format||MapInfo TAB (MITAB)|
6) Add NeighborFinder
Add a NeighborFinder transformer, which we can use to determine the nearest park to each address, and how far away it is.
Connect the Junction transformer to the NeighborFinder:Base input port and the Parks feature type to the NeighborFinder:Candidate input port:
Inspect the parameters. We want to find only one neighbor, with no maximum distance.
7) Add AttributeRenamer
Add an AttributeRenamer transformer to rename the attribute _distance to ParkDistance:
Add a bookmark around the section of the workspace that deals with parks. Run that section of the workspace by selecting the bookmark and choosing Run to Contained:
Inspect the output to ensure it is correct.
8) Save as Template
Because this project may be continued at a later date, save the workspace but use File > Save As Template. When prompted, be sure to have the Include Feature Caches option checked:
Now if we come back to this project later, we can reopen the template and have all our cached data ready for use.
By completing this exercise you have learned how to: