Exercise 4d | Readers |
---|---|
Scenario | FME Workspace Author |
Data | Property Parcels (AutoCAD DWG/PostGIS) Public Art (Microsoft Excel) City Properties (Esri Shapefile) |
Overall Goal | Create a list of public art on city property |
Demonstrates | Managing and controlling Feature Types |
Start Workspace | C:\FMEData2015\Workspaces\DesktopBasic\Exercise4d-Begin.fmw |
End Workspace | C:\FMEData2015\Workspaces\DesktopBasic\Exercise4d-Complete.fmw |
This example continues where a previous one left off. In that example you created a workspace to determine what pieces of public artwork are located on city property.
Now the data must be written out so that it can be used by the finance team. However, before that, they have asked that we also divide the data up into separate postcodes.
1) Inspect Data
Start the FME Data Inspector and open the datasets:
Reader Format | Esri Shape |
Reader Dataset | C:\FMEData2015\Data\Addresses\ForwardSortationAreas.shp |
This dataset contains a set of polygons marking the postcode boundaries for the city.
2) Update Dataset Parameter
Start Workbench and open the beginning workspace. To get this data into the workspace we could simply add a new Reader. However, since we already have a Reader to handle Shape data, we can use that, update the source dataset parameter, and simply import the feature type definition.
So, firstly locate the source dataset parameter for the Shape Reader:
Double-click the parameter to edit it. If the new postcode Shape file was in the same folder as the CityProperties Shape file, we could simply select both of them with the regular browser.
However, since they are not, we must do this a little differently.
Click the drop-down arrow and select Open Advanced Browser.
In the advanced browser, click Add Files, browse to the postal code data (ForwardSortationAreas.shp) and select it:
Click OK and OK again to close these dialogs.
3) Import Feature Type
Now both Shape files will be read when the workspace is run. However, the postcode data will be discarded because there is no matching feature type.
So, select Readers > Import Feature Type from the menubar.
When prompted, select the Shape Reader to import the feature type to. Then, in the next dialog, set the format and dataset parameters, the same way as they usually are.
Now click OK. When prompted to select the types to import, you can click OK again. CityProperties won't be added again because FME recognizes it exists already. However, a feature type for ForwardSortationAreas will be created:
4) Add PointOnAreaOverlayer
Now add a further PointOnAreaOverlayer transformer to copy the postcode info onto matching art features. The ForwardSortationAreas will be the Areas, the output from the final Tester will be the Points:
If you add an Inspector and run the translation now, you'll find that there is a postcode (CFSAUID) attribute added to the public art features.
5) Add Writer
The finance team (who requested this data) would like it as a SpatiaLite database. So add a Writer with the following parameters:
Writer Format | SpatiaLite |
Writer Dataset | C:\FMEData2015\Output\Training\PublicArt.sl3 |
Add Feature Type(s)" section of the dialog, choose the option to "Copy from Reader." When prompted, select one of the existing Public Art Reader feature types- for example Mount Pleasant - and click OK. A new Writer feature type will be added that is a copy of the Reader equivalent.
Connect it to the final transformer output:
6) Edit Schema
The schema we created is not exactly what we want, so it should be edited. What we need is:
- name - string(46)
- title - string(32)
- address - string(30)
- postcode - string(3)
So open the properties dialog for the new Feature Type. Click on the User Attributes tab and edit the schema to what is required, but don't click OK yet. Notice that we can't use upper-case characters in a field name for SpatiaLite.
7) Set Feature Type Parameters
Now click on the Format Parameters tab. These are parameters that apply to this table. We're only creating one table, but if there were more each could have different values for these parameters. Ensure Create Spatial Index is set to yes, so that the output dataset can be queried more efficiently:
Again, don't click OK yet.
8) Set "Fanout"
Click on the General tab. Check the box marked Fanout by Attribute and select the attribute CFSAUID:
A fanout is an advanced function that will be useful here. By checking this box, and selecting the postcode attribute, we will get a separate table of features for each different postcode.
Click OK to close the dialog.
9) Map Schema
The final step is to map the schema correctly, as nothing is connecting up as yet. Draw connections between:
- Name - name
- Title - title
- Address - address
- CSFAUID - postcode
10) Run Workspace
Save and run the workspace. Inspect the output in the FME Data Inspector. You should find there are 70 features on a number of layers, each defined by a postal code:
Congratulations!
You have now:
- Imported a Feature Type Definition
- Added a Writer
- Added a Writer Feature Type
- Modified Feature Type parameters
- Used a fanout