Working with Geodatabase Subtypes: Writing A Subtype

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2022.0

Introduction

A subtype defines aspects of a geodatabase schema that relates to data classification. In other words, instead of creating different feature classes for a set of features, a subtype functions as a way to define a subset of features within an individual geodatabase feature class. An attribute in the feature class stores integer values that define the subtype, and a subtype table contains definitions for the corresponding integer value. For instance, a table named “Road” may have an attribute field called "Condition", whose values map to a subtype containing values good, moderate, and bad.
In general, each table can have only one subtype, all codes must be unique and be valid integers, and all code:description pairs must be unique.
It should be noted that a subtype is specific to a particular feature class. Therefore, it cannot be shared by other feature classes in the geodatabase in the way that a domain can be shared.
 

Reading Subtypes

When reading a Geodatabase, FME has an option to "Resolve Subtypes".
ReaderSubtype.png

When this option is checked, the format attribute geodb_subtype_name will be populated with the descriptive value contained in the subtype definition.
 

Writing Subtypes

When Creating Subtypes we recommend using a Geodatabase Template as described in How to Use an Esri Template. This is generally easier and more flexible than defining subtypes within FME feature types. Due to the fact that a subtype can only apply to a single feature class, it is not possible to create a new table and associate it with an existing subtype. As such, when writing geodatabase subtypes, the workflow requirements will fall under the following scenario:

  • Write to an existing table containing an existing subtype.

The above scenarios will be controlled primarily by the following parameters:

  • Validate Features to Write parameter: Yes / No

 

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 Required ArcGIS License Types for FME Geodatabase Formats.


Video



Scenarios

Scenario 1: Writing to an existing table containing an existing subtype

No additional work is required to write to an existing table with an existing subtype. It’s not even necessary to set the writer parameter “Validate Features to Write” in order to validate the subtype value. A feature with an undefined subtype value will be rejected anyway, with the following error:

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

 

Limitations

At the time of writing, FME will not allow you to associate different domains based on a particular subtype. For instance, 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 a subtype definition containing the values of Small, Medium, and Large. In order to achieve this, you would need to create the domain:subtype relationship in ArcGIS.
 

Scenario 2: Writing to a new table and creating a new subtype 

Source Data

Parks (MapInfo TAB - MITAB)
ParksSource.png


Step-by-step Instructions

1. Read Source Data
In FME Workbench, open a blank workspace. Add a MapInfo TAB (MITAB) reader to the canvas and browse to the Park.tab dataset, which can be downloaded from the Files section of this article. Then click OK to add the reader. The data in this file will be used to calculate Park area values that will be subject to the subtype definition in the destination geodatabase.
ParksReader.png

2. Calculate Area
Next, we will calculate the area of each park polygon. Add an AreaCalculator to the canvas and connect it to the Parks reader feature type. We can accept the default parameters.  The value for the calculated area will be stored in an attribute named _area.
 
3. Map Calculated Values to Subtype Codes
The AttributeRangeMapper will be used to map values coming from the _area attribute (created to the subtype codes we will apply to the subtype definition. The code applied will be based on whether the initial values fall into a specified range. Add an AttributeValueMapper to the canvas and connect it to the AreaCalcultor. Open the parameters, set the Source Attribute to _area, then change the Output Attribute to ParkSize.  For the Range Lookup Table, enter the following values:

From To Output Value
  10000 1
10000 1000000 2
1000000   3

AttributeRangeMapper.png

4. Write Features & Writer to Subtype Field
Add an Esri Geodatabase (File Geodb) writer to the canvas and browse to a location to save the output geodatabase. Set the Feature Class or Table Definition to Import from Dataset, then open the Parameters. 
Writer.png

In the Parameters, enable Overwrite Existing Geodatabase, and then set the Template File Geodatabase to Subtypes.gdb. Click OK twice to finish adding the writer. 
WriterParams.png

In the Import Writer Feature Types dialog, navigate to the template geodatabase (Subtypes.gdb) then click OK. 
ImportWriter.png

Since there is only one feature class in the template geodatabase, it will get added automatically. Connect the Parks writer feature type to the AttributeRangeMapper. 

5. Define Table Handling to Update 
Now we need to define how the table will be handled, since we already have 80 features with the subtypes attached and we are only adding attributes, we will need to update the incoming features instead of creating new ones. Open the Parks writer feature type parameters. In the General section, change the Feature Operation to Update, the Table Handling to Use Existing, and the Match Columns to ParkID, then click OK. 
UpdateExisting.png
 
6. Save and Run the Workspace
Save and run the workspace. View the output geodatabase in ArcMap to confirm the subtypes were mapped correctly. 
OutputArc.png
OutputArcCat.png

 

Data Attribution

The data used here originates from data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.