Exercise 1 Fanning Out Development Zones
Data Zoning Data (MapInfo TAB, Esri Shapefile)
Overall Goal Create a separate Shape dataset for each type of development zone
Demonstrates Feature Type Fanouts and Zipped Datasets
Start Workspace None
End Workspace C:\FMEData2016\Workspaces\DesktopAdvanced\ReadWrite-Ex1-Complete.fmw
C:\FMEData2016\Workspaces\DesktopAdvanced\ReadWrite-Ex1-Complete-Advanced.fmw

You’ve been given a dataset of development zones and asked to separate each zone type into a separate Shapefile and send it back with everything zipped together in a single file.

The requester thinks this will be a difficult task; but with FME you should be able to do it in about two minutes.


1) Inspect Source Data
Inspect the source dataset for this translation in the Data Inspector. The source data is a MapInfo TAB dataset:

Reader Format MapInfo TAB (MITAB)
Reader Dataset C:\FMEData2016\Data\Zoning\Zones.tab

Check the geometry type used and notice that there is a field called ZoneName. We need the first characters of this field (up to any "–" character) for our fanout.


2) Start Workbench
Start Workbench and generate a workspace to translate the MapInfo source data to Esri Shapefile.

By default the workspace will include a GeometryFilter and multiple output feature types. However, we know the data is polygon only (because we inspected it first, right?) so we can remove much of this.

So, delete the GeometryFilter transformer and all of the Writer feature types except Zones_polygon. You’ll end up with something that looks like this:


3) Add StringReplacer Transformer
To remove everything after the “-“ character in the ZoneName field, place a StringReplacer transformer into the workspace, between the Reader and Writer feature types.


4) Set Parameters
Open the parameters dialog for the StringReplacer. Set the following parameters:

  • Attributes: ZoneName
  • Text to Match: -(.+)$
  • Replacement Text field: leave empty
  • Use Regular Expressions: Yes (this is very important)

This regular expression will search out the dash character – and anything after it – and replace it with nothing (i.e. delete it). Click OK to close the dialog.


5) Set Fanout
Open the Feature Type Properties dialog for the Writer feature type. Click the drop-down arrow next to the Shapefile name parameter and select Attribute Value > ZoneName:

Click OK to close the dialog.


6) Save and Run Workspace
Save the workspace. Run the workspace with the Prompt option turned on. When prompted manually change the Destination Directory to: C:\FMEData2016\Output\Zones.zip

NB: Manually enter the name directly into the field. Don't click the browse button first. You cannot enter a filename in the browse dialog.

Locate the output folder in a file browser. You should see the file Zones.zip:

If you open it up there will be inside a Shapefile dataset for every zone type.


Sister Intuitive says…
A feature type fanout results in multiple Shapefile datasets because each Shapefile is a layer (feature type). As an advanced task, repeat the exercise but write a separate DWG file for each zone type. In that scenario you'll need to use a Dataset Fanout instead. Be sure to add ".dwg" as a suffix to the fanout.

CONGRATULATIONS
By completing this exercise you have learned how to:
  • Use a feature type fanout to write separate feature types
  • Use a .zip extension to create zipped output datasets
  • (Advanced) Use a dataset fanout to write separate datasets

results matching ""

    No results matching ""