Show Navigation | Hide Navigation
You are here:
Geoprocessing > Automating your work with models > Using ModelBuilder

Feature sets and record sets

Release 9.3
Last modified January 26, 2009
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Using ModelBuilder"

Related Topics

Any model that uses a feature class or feature layer as input can be modified to accept a feature set. A feature set allows the user of your model to interactively enter features.
Any model that uses a table as input can be modified to accept a record set. A record set allows the user of your tool to interactively create a table of records.

Feature and Record Sets

Basic steps

The basic steps, as illustrated below, for modifying an existing model that accepts a feature class as input to accept a feature set instead are

  1. In ModelBuilder, right-click a feature class variable and click Properties.
  2. In the properties dialog box, click the Data Type tab.
  3. Select the Feature Set data type.
  4. Import a schema that defines the attributes, geometry type, and symbology. You can import a schema from an existing dataset, layer file, or layer.

  5. Converting a feature class variable to a feature set
    Converting a feature class variable to a feature set

  6. Click OK.
  7. Save and close the model, then open the model tool from the ArcToolbox window.

The same steps apply for interactive row input except

Learn more about changing the data type of a variable.

More details about creating models with feature and record sets are found below.

Uses for feature and record sets

Any tool that uses a feature class or table as input also accepts a feature or record set. This means that if you want to interactively enter features or records for any tool, you can build a simple model around the tool and change the data type of the input from feature class to feature set, or from table to record set.

For example, the model below is built around the Geocode Addresses tool. Geocode Addresses takes a table containing an address field and ZIP Code field (depending on the type of address locator used). In this model, the input table variable has been converted to a Record Set data type. The schema of the record set contains the definition of the three fields (Name, Address, and Zip). In addition, the Zip Code field has a coded value attribute domain that enables the drop-down list of valid ZIP Codes. When the model is opened from ArcToolbox, the user adds records and attributes, and the result of running the model tool is a point feature class of the address locations.

Geocode Addresses with Record Set

The above is just one use of a record set variable. Another way you might use a record set include converting XY coordinates to point features, as illustrated below.

Creating features from a table of XY coordinates

Here is a list of just some of the ways you might make use of a feature set:

Creating a model tool to allow interactive input

To enable interactive entry of features, you need a model variable with the feature set data type. For interactive entry of records, you need a model variable with the record set data type. There are two ways to create a feature or record set variable:

Feature sets are disabled in ModelBuilder

Feature sets are disabled when opened in ModelBuilder

If you open a feature set variable in ModelBuilder, either by double-clicking the variable or by right-clicking and choosing Open, the dialog box that opens will be disabled—you are not able to enter features. (This is not the case for record sets—see below). This means you cannot run a model containing a feature set from ModelBuilder. The model can only be run by opening it from ArcToolbox or the Command Line window. Since the only way to use the feature set is by opening the model tool from ArcToolbox, you need to make the feature set variable a model parameter. In ModelBuilder, right-click the feature set variable and choose Model Parameter. A check mark will appear next to Model Parameter signifying that the variable is a model parameter.
If you need to run a model containing a feature set from within ModelBuilder, you need to replace the feature set variable to a feature class variable, supply a value for the variable, and then run the model. The steps below describe one way to convert the variable and run the model.
  1. Disconnect the feature set from the tool by selecting and deleting the connector.
  2. Add data to the tool.
  3. Connect the added data to the tool.
  4. Run the model.
  5. Delete the data variable added in step 2.
  6. Reconnect the feature set you disconnected in step 1.

Record sets can be used within ModelBuilder

Unlike feature sets, you can open a record set variable in ModelBuilder, add records, and enter attributes. You can then run the model from within ModelBuilder.
Any records you add to a record set in ModelBuilder will appear in the model tool dialog. This means you can populate the record set for the user. For example, the illustration below shows a table that has been populated with four records, each one containing a different soil type and a suitability score. When the model tool is opened, the user doesn't have to enter records—they just change the suitability score.

Populating a record set

Populating a record set for your tool is a good technique. Just be aware that the user of your model tool still has the ability to add and delete records and change their attribute values from the tool dialog.

About schemas

A schema defines the attributes and geometry type (point, line, or polygon) of the features to be entered. The schema can also define the symbology to use when displaying new features, as illustrated below where points are symbolized according to the Type attribute. If the schema contains attributes with a coded value attribute domain, the values will appear as a drop-down list, illustrated below.

Feature Set schema

A record set schema only defines the attributes. If an attribute has a coded value attribute domain, it will appear as a drop-down list as illustrated above.

Where schemas come from

The schema for a feature set can be one of the following:

For a record set, the schema defines the attributes and attribute domains of each record. The schema can be one of the following:

Changing a schema

NOTE: When you apply a schema, the schema is read and stored with the model variable. If you subsequently change the schema—for example, changing the symbology or adding a coded value domain—you need to reapply the schema.

  1. In ModelBuilder, right-click the feature or record set variable and choose Properties.
  2. Click the Data Type tab.
  3. Choose the schema (dataset, layer file, or layer) again and click OK.
Because the schema is stored with the feature or record set, you can delete the schema once it has been applied.

Note that layers and layer files can also be used to define the symbology of output datasets, as described in Setting symbology for output data. When a layer or layer file is used for defining output symbology, the layer or layer file must exist when the tool is run. This is not the case for schemas—the schema is read (from a dataset, layer, or layer file) and stored with the model.

Schemas should contain the minimal number of attributes

The schema should only have the attributes you need for your model to run. Extra unneeded attributes clutter the user interface and cause confusion.

About attribute domains

Attribute domains are rules that describe the legal values of a field. If a field in your template has an attribute domain, the values will be displayed in a drop-down list, as illustrated below.
Attribute domains in a record set

Learn more about attribute domains.

Schemas are optional

If you don't specify a schema, the feature and record set will only allow importing of features or rows from an existing dataset, but the interactive digitizing of features or adding of rows will be disabled.

Noneditable fields are ignored

Some fields, such as OBJECTID and Shape_Length, are special fields that can only be edited internally by ArcGIS. You can view the contents of these fields, but you cannot edit (update) the contents. These noneditable fields are never shown as attributes of a feature or records set.

Schemas and existing datasets

The feature and record set controls allow you to enter an existing dataset by clicking Use features from Use features from or Use records from Use records from.
When using an existing dataset, the dataset is checked to determine if the schema attributes are found in the dataset. If any of the schema attributes are missing from the dataset, a warning is issued.

NOTE: Since a warning is issued—not an error—the tool can still be executed. If your model tool depends on fields in the schema being present in the dataset, your model may fail.

If you need to ensure that fields in the schema are found on the dataset, you can use the field check script tool described in Branching: Implementing if-then-else logic. The field check script checks for the existence of a field on a dataset and outputs two Boolean variables, which can be used as preconditions in your model.
The illustration below shows the Geocode Address model described above with additional logic to check the existence of the Address and Zip fields.

Using the field check script

Feature and record set schemas cannot be altered by tools

Feature and record set variables cannot have their schemas altered. The following tools alter schema:

If you use a feature or record set as input to these tools, an error will be generated.

If you need to use these tools with a feature or record set, use Copy Features or Copy Rows to create a new dataset, then use this new dataset as input, as illustrated below.

Model using Copy Features on a Feature Set

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.