Files
Introduction
This article will show you how to use an Esri template in FME. While FME can create most attributes of a geodatabase, it is strongly recommended that you use the native ArcGIS client to do so. This article will demonstrate how domains and subtypes created inside ArcGIS can be applied to features using FME. By creating ‘The Geodatabase structure’ inside ArcGIS, the user ensures the most efficient method of migrating or updating data is followed, requiring minimal modifications.
What is an Esri Template
An Esri template is a file that can be used to map FME output to a desired schema or structure. The template can either be an XML Workspace Document or a file geodatabase (.gdb). This template will allow FME to create the geodatabase structure with a complete schema of the template. This includes subtypes, domains, relationships, network information, and annotation symbols.
If you had a geodatabase document with existing attachments, you would not need to use an Esri template to write additional attachments. The Esri Template is only needed if the attachments and relationships are not in the pre-existing schema
How to Use an Esri Template
As stated above, there are two types of Esri templates: a file geodatabase (.gdb) or an XML Workspace document. A geodatabase file is a geodatabase with a pre-defined structure. It can either contain data or not. An XML Workspace document is a simple XML document that contains the definitions of the originating geodatabase. This document contains the schema and possibly the data. When FME uses an XML workspace document, it will only import the schema, regardless of whether the data is attached to the document or not.
How to Create an Esri Template
ArcGIS Desktop
To create an XML Workspace document, you have to open the geodatabase in Catalog view (either ArcCatalog or ArcMap will work, or ArcGIS Pro) and right-click the geodatabase > export > XML Workspace Document (export the schema only). This allows the user to determine if the XML document will contain the schema or the schema and data.
ArcGIS Pro
For ArcGIS Pro, the process for creating an XML Workspace Document differs slightly. Rather than being able to right-click and export a document, a tool is required. This can be found under Analysis Tab > Tools > Toolboxes tab > Data Management Tools > Distributed Geodatabase > Export XML Workspace Document. By filling out the parameters, a template will be created.
FME will not use the data from an XML Workspace Document. If you plan to use an XML Workspace Document for schema purposes only, please ensure Export Options is set to Schema Only.
Why Use an Esri Template
The main reason to use a template is simplicity. While the geodatabase structure can be created in FME, it requires more upkeep between translations. If you want to create a geodatabase output using a predefined schema, using an XML Workspace Document or a copy of a file geodatabase is the easiest method.
This method also ensures that the workspace does not have to be modified extensively to apply updates to the output. This is because the process for creating and applying domains in FME differs. In order to create domains or subtypes with FME, attribute parameters are set as the type domain/subtype_codes. This method works for the initial translation of data, meaning the translation where the output is created for the first time. All subsequent translations to that same output would require altering the workspace. Rather than having the data type set as coded_domain/range_domain or subtype_codes, the type would need to be altered to the default fields corresponding data type, for example, 'char' or 'double'. Once the geodatabase has been created, the workspace needs to be altered to apply all future updates.
Requirements
The Esri Geodatabase (File Geodb) reader/writer used in the following example requires that a licensed version of ArcGIS be available to the user. For more information on required ArcGIS license levels, please see Comparison of Esri-Based Readers and Writers in FME.
Video
Source
For this example, we will be looking at the City of Vancouver's Water and Sewer infrastructure. The data we will be focusing on consists of Control Valves, Hydrants, and different classifications of Watermains (Abandoned, DFPS, Distribution, and Transmissions mains). The domains we will be looking at are the Mains Materials, Diameter, Life Cycle Status, and Lining features. The domains and their possible values for each are as follows:
Domain Name: wDomainMainMaterials
| Ductile Iron | Cast Iron | Wood | Galvanized |
| High Density Polyethylene | Poly Vinyl Chloride | Asbestos Concrete | Concrete |
| Steel | Clay | Copper | Unknown |
| Other |
Domain Name: wDomainMainDiameter
| 20 | 25 | 30 | 40 | 50 | 65 | 75 | 100 |
| 150 | 200 | 250 | 300 | 350 | 400 | 500 | 550 |
| 600 | 675 | 700 | 750 | 775 | 800 | 850 | 900 |
| 1000 | 1050 | 1200 | 1350 | 1500 | 1800 | 1900 |
Domain Name: wDomainLifecycleStatus
| Proposed | Active |
| Removed | Abandoned |
Domain Name: wDomainLiningMaterial
| Cement Lined | CENT |
| Coal Tar | Epoxy |
Step-by-step Instructions
1. Start FME Workbench
Start FME Workbench. In Windows, this is found under Start > All Programs > FME Form > FME Workbench. Also, download the attached data, which can be found under the Files section of this article. If you do not have it already, unzip it.
2. Open Workspace
Open the attached TemplateWorkspaceStart.fmwt
Inside the workspace, you will see AttributeManager transformers connected to each of the reader feature types. These are used to correctly map domains to their corresponding reader feature.
This image shows the Control Valve CAD feature, having its attributes mapped to the correct output field and domain definition.
The 2DForcer that is attached to the water main and hydrant features ensures the features are two-dimensional.
The AttributeValueMapper transformers attached to the water main features map the corresponding feature to the domains. In this case, the first AttributeValueMapper maps the source values to the correct domain for Materials, and the second AttributeValueMapper maps the source values to the correct domain for the Lining attribute.
3. Add a Writer to the Workspace
There are two different methods of adding a writer to the canvas to use the correct schema: an XML Workspace Document or a file geodatabase template.
If you're following along with this demo, only select one of the options or delete the writer before proceeding with the other option.
Option 1: XML Workspace Document
Add an Esri Geodatabase (File Geodb) writer to the canvas. Next, select a location and name for the future geodatabase. Set the Feature Class or Table Definition to Import from Dataset. Then click Parameters.
For Import XML Workspace Document (Schema Only), select the XML Workspace document provided (XMLWORKSPACEDOC.XML).
If writing to an existing geodatabase that contains a different schema, you can click the Overwrite Existing Geodatabase option. This option will overwrite and delete both the data and schema of an existing geodatabase if your output geodatabase location contains a geodatabase with the same name.
Click OK twice.
When the Import Writer Feature Types Dialog appears, set the format to Esri Geodatabase (XML Workspace Document) and the dataset to the provided XML workspace document. Click OK.
When the Select Feature Types Dialog appears, click Select All, then click OK
Option 2: .gdb File Template
Add an Esri Geodatabase(File Geodb) writer to the canvas and select a location and name for the future geodatabase. Set the Feature Class or Table Definition to Import from Dataset. Then click Parameters.
In the parameters dialog, enable Overwrite Existing Geodatabase, then set the Template File Geodatabase to SourceGeodatabase.gdb, and click OK twice.
Overwrite Existing Geodatabase must be checked in order to use an existing .gdb file as a template.
In the Import Writer Feature Types dialog, set the Dataset to the source template (SourceGeodatabase.gdb), then click OK.
When the Select Feature Types Dialog opens. Select All, and then click OK.
4. Map Input Features to Output Features
Connect the Control Valve flow to the wControlValve output, the Hydrants flow to the wHydrant, and the 4 different main features to the wMain feature.
Now, we need to manually map a couple of attributes. Expand the 2DForcer_2 as well as the wHydrant. For the wHydrant feature, manually map ASSET_NUMBER to FacilityID, and OFFSET_FROM_VALVE_M to LocationDescription by clicking and dragging from the arrows.
Then, for the wMain feature, manually map the DIAMETER_MM to Diameter.
5. Save and Run the Workspace.
Save the workspace and then run it. A new geodatabase will be created, complete with the attached schema. You can view your results using ArcMap.
Check the wMain, wHydrant, and wControlValve features to ensure the domains were followed.
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.