ArcGIS for Desktop Cookbook
上QQ阅读APP看书,第一时间看更新

Creating subtypes

Subtypes are properties of feature classes or non-spatial tables. The subtypes gather the features from a feature class or records from a non-spatial table that share the same attribute values using an attribute field. The attribute field that groups the features must be of the data type Short or Long integer, and it will be named the subtype field. A feature class can have only one subtype field. You can assign different behaviors to individual subtypes from a feature class/table. Generally speaking, the behavior is defined by the actions or characteristics of features in a geodatabase. A subtype has a code and a description. After you have defined the subtypes for a subtype field, you can change everything related to a subtype: change the value or description of code, add more codes, and delete code. The subtypes help you in the geometry editing process and prevent errors when editing feature attribute values. The subtypes maintain the integrity in a geodatabase.

Getting ready

You will continue to work with geodatabase schema by grouping features from the feature classes that you created in the previous Creating a feature class recipe. The integer subtype fields are the following: BD for Buildings, HType for Watercourse and WatercourseL, and CAT for LandUse.

How to do it...

Follow these steps to define subtypes using the context menu in ArcCatalog:

  1. Start ArcCatalog. In Catalog Tree, go to <drive>:\PacktPublishing\Data\MyGeodatabase\ Topo5k.gdb\Buildings.
  2. Right-click on the Buildings feature class, and navigate to Properties | Fields. You will define five subtypes for the BD attribute field. Select the Subtypes tab in the Feature Class Properties window. For Subtype Field, select the drop-down arrow and choose BD. In the Subtypes section, you have a default subtype with Code with the value 0 and Description with the value New Subtype. Change Description of the first subtype by typing Unknown.
  3. Continue to create subtypes as shown in the following table:
  4. For Default Subtype, choose the Dwelling subtype. Click on Apply and on OK. Open the Feature Class Properties dialog for the Buildings feature class to check the subtypes you just added. Right-click on the Buildings feature class, and choose Properties | Subtypes. You should see something similar to the following screenshot:
    How to do it...
  5. In Catalog Tree, select the Hydrography feature dataset. Right-click on the Watercourse feature class, and choose Properties | Fields. Select the Subtypes tab in the Feature Class Properties window. You will define five subtypes for the HType attribute field. For Subtype Field select the drop-down arrow, choose HType, and add the following subtypes:
  6. For Default Subtype choose the River subtype. Click on Apply and on OK. Open the Feature Class Properties dialog for the Watercourse feature class to check the subtypes you just added.
  7. Repeat step 4 to create subtypes for the WatercourseL feature class using the same codes and descriptions.
  8. Repeat step 4 to create subtypes for the LandUse feature class using the CAT (Description: Category) attribute field and the following subtypes:
  9. For Default Subtype, choose the Arable subtype. Click on Apply and on OK. Open the Feature Class Properties dialog for the LandUse feature class to check the subtypes you just added.
  10. Inspect the results in Subtypes in the Feature Class Properties dialog.

How it works...

The subtypes will help you to edit feature geometry and attribute fields faster. The default subtype is used as the default edit target for the Watercourse feature class when you start an edit session in ArcMap. In the Feature Class Properties dialog, you can add more subtypes for the BD attribute field, and you can delete a subtype or change Code and Description.

Note

If you delete all code, your feature class will not have subtypes anymore, and all rules and behaviors related to subtypes will be corrupt or lost for the feature class.

Sometimes, when you are establishing codes and descriptions for a subtype field, it is impossible to anticipate correctly all possible values. It is good practice to add code that covers all unforeseen values: Code: 42 and Description: Other terrains. Another good practice is to add code that refers to the situation in which you know the values for all other attribute fields, but you are not sure about the subtype, and it will be defined later: Code: 0 and Description: Unknown.

See also

  • For information about how you can enforce attribute values for a feature class table, please refer to the following Creating domains recipe