Reading Subtypes and Domains

Reading geodatabase subtypes and domains simply involves adding the feature type that contains the subtype and domain fields to your workspace.  For example, the "water_distribution_lines" feature class has a field "Diameter" mapped to a code domain called "Diameter":

User-added image


When you add this feature type to FME you have the option to "Resolve Subtypes" and "Resolve Domains" on the geodatabase reader.  This adds a new attribute with the suffix _resolved to your source schema.  The _resolved attribute contains the description of the subtype or domain.

1.  Add a Geodatabase Reader to your workspace and click on "Parameters".

User-added image


2.  Check "Resolve Domains" and/or "Resolve Subtypes".

User-added image
 
3.  The source schema now contains both the user-defined "Diameter" field and a "Diameter_resolved" field.
 
User-added image

 

 


Writing Subtypes and Domains

Domain Writing Scenarios

FME has options to write to an existing table or to create a new table, but when a domain is added to the mix there are a number of scenarios:
  • Write to an existing table using an existing domain
  • Write to a new table using an existing domain
  • Write to a new table creating a new domain
These scenarios will be controlled by a series of parameters, namely:

Table Exists                               Yes/No
Data Type                                   coded_domain/range_domain
Validate Features to Write        Yes/No

Writing to an existing table using an existing domain:

1. First, check the settings on the Drop Table First, Truncate Table First.

Feature Type Properties

2. If you wish to validate incoming data, then you must set the writer parameter "Validate Features to Write" to Yes.

User-added image
 

Writing to a new table using an existing domain:

1. Drop the existing table if necessary.
 
Feature Type Properties
 

2.  Next, the attribute that needs to be associated with the domain should be given the data type coded_domain or range_domain (depending on its type) in the schema definition:

User-added image


3.  Click on the Edit button next to code_domain (above), uncheck the "Create Domain" box and fill in the name of the existing domain:
 
User-added image

 

Writing to a new table and creating new domain:

Generally we recommend that you use ArcGIS to create and define domains and simply use FME to associate attributes or validate data when inserting new features.  However, creating domains is possible with FME.

The process is the same as for using an existing domain, up to opening the edit dialogue.  At the point you would check "Create Domain", enter a new domain name, and define the codes and descriptions for that domain.
 
User-added image
 
 

Limitations:

  • It is not possible to modify an existing domain
  • Creating a domain is a one-off translation; you would set the data type to coded_domain for the initial process, but subsequent loads of the data should be done with the data type changed back to the actual type (char, integer, etc.)
  • It is not possible to create a domain dynamically; i.e. the domain definition cannot be set as part of the workspace process, but must manually be defined prior to execution

 

Subtype Writing Scenarios

Because a subtype only applies to a single feature class, it is not possible to create a new table and associate it with an existing subtype.  Therefore the scenarios are:
 
  • Write to an existing table with an existing subtype
  • Write to a new table creating a new subtype

These scenarios will be controlled by a series of parameters, namely:

Table Exists                              Yes/No
Data Type                                 subtype/subtype_codes
Validate Features to Write        Yes/No
 

Writing to an existing table with an existing subtype:

1.  Check the values of the Drop Table First and Truncate Table First parameters
 
Feature Type Properties


When writing to a table with an existing subtype you do not need to set the writer parameter "Validate Features to Write".  A feature with an undefined subtype value will be rejected regardless, with the following error:

ERROR
For the '<ClassName>' table/feature class the subtype code of '<Value>' is not valid for the subtype field '<SubtypeName>'
 

Writing to a new table and creating a new subtype/domain


Again it's recommended that you use ArcGIS to create and define subtypes, and simply use FME to enter subtype code values when inserting new features.  However, creating subtypes is possible with FME.

1.  Drop the existing table if necessary.
 
Feature Type Properties


2.  Set the attribute that contains the subtype to type "subtype_codes":
 
User-added image

3.  Click on the Edit button (above) and enter the subtype codes and descriptions:
 
User-added image

 

Limitations:

Currently FME will not allow you to associate different domains based on a particular subtype.  For instance, in the above example, you would not be able to set range domains of 0-50,000; 50,000-100,000; 100,000-250,000 and apply them to the Small, Medium and Large park subtypes.  You would need to create the domain:subtype relationship in ArcGIS to achieve this.