ArcMap

Best practices for using layer definition queries while creating features

ArcGIS 10 introduced the concept of editing with feature templates, which define a new feature’s symbology and default attribute values, among other properties. Anytime I want to add a feature, I use the Create Features window, which displays a list of available feature templates and tools for creating new features.

Sometimes, though, I do not see the template I want to use in the Create Features window. This could be because there are no templates for the layer, but it could also be that the template exists but is being filtered out of the Create Features window. The underlying philosophy for determining whether ArcMap shows a feature template is that new features created with the template must be visible after creation. Therefore, templates are hidden whenever new features would immediately disappear and not be displayed on the map.

While a layer being turned off is one of the more obvious reasons why feature templates are not shown on the Create Features window, layer definition queries can be subtle causes. A definition query displays only the subset of features that match an attribute query defined on the Layer Properties dialog box; the remaining features are not drawn on the map or shown in the attributes table.

This post provides an overview of and best practices for the use of definition queries while creating features.

Only feature templates with default attribute values matching the definition query are displayed.
While preparing to write this post, I spent some time reviewing technical support incidents and forum posts about feature templates and definition queries. I discovered a common misunderstanding that removing a definition query is the only way to get a feature template to appear in the Create Features window. In reality, a feature template is shown on the Create Features window when the template’s default attribute values match the definition query. If the default attribute values do not satisfy the query, the feature template is hidden because the new feature would disappear from the map as soon as it is created.

I am working with some data from Zion National Park and surrounding communities, including a Roads layer where the roads have been symbolized by type: Freeway, Major road, Minor road, and Unpaved road. When I start editing, ArcMap creates feature templates for each of the symbol categories. I now have four feature templates for the Roads layer. A symbol and a corresponding default attribute value for the field being used to symbolize the feature is assigned to the feature template. I can review the symbol and default attributes by double-clicking a feature template to open the Template Properties dialog box. All the feature templates are displaying in the Create Features window because all the features in the layer are being drawn on the map.

However, suppose I decide that I only want to draw the major roads and not display any of the other road types. To do this, I set a definition query on the layer where “TYPE” = ‘Major road’. When I do this, only the Major road feature template displays on the Create Features window because it is the lone feature template with a default attribute value of Major road. The other feature templates with default attribute values of Freeway, Minor road, and Unpaved road for the TYPE field will be hidden because those road types are excluded from drawing by the definition query.

Definition queries on any field can affect feature template visibility.
Filtering feature templates from the Create Features window can happen if the definition query is applied to any field in the layer, not just the field being used to symbolize it. Later, I change the Roads layer’s definition query to display only the roads that are major AND are maintained by the county. At this point, even my original major road feature template disappears from the Create Features window.

While the feature template’s default attribute value satisfies the road type portion of the query, the maintenance field’s value does not. Therefore, I need to update the maintenance field’s default attribute value. To do this, I click the Organize Templates button on the Create Features window to open the Organize Feature Templates dialog box, click the Road layer’s name, open the properties for the Major roads template, and set the maintenance value to County. I could also copy the Major roads template and make a new template specifically for these default attribute values.

It is a good idea for me to add a clear name and description to the template’s properties to indicate that this feature template is set up for creating major roads that are maintained by the county. The extra information in the template properties can help me easily find and distinguish templates.

Feature templates can be created for all layers, even if there is a definition query.
ArcMap always automatically creates feature templates to match the symbols in all layers the first time I start an edit session in a map, regardless of whether the layer has a definition query. Although a feature template does not display on the Create Features window, it does not mean that it does not exist for the layer. To view all templates in the map, I can open the Organize Feature Templates dialog box and click a layer in the list. If the feature template really does not exist, I can also create a new template for a layer with a definition query by using the Create New Templates wizard.

When a template is created, the values for the fields that are not being used to symbolize the layer are often null (unless I have set up default values in the geodatabase, in which case they are used). This means that the template’s default attribute value for a field with the definition query could be null and must be populated to make the template display. The feature template for the major county-maintained roads had a value of <Null> for the Maintained By field before I changed it to County to satisfy the definition query. However, I need to be careful when assigning a template’s default attribute values, since they should only refer to values that will be used frequently. A name or ID that is only common to a few features should not be set as default values for a template to avoid having to update the attributes after each feature is created. Therefore, I may want to revise my definition query when editing if I expect only a few features to match it.

Sometimes, removing a definition query is the best way to make a feature template display.
In the same map, I want to create a new intermittent stream feature. On the Organize Feature Templates dialog box, there are two templates—one for Perennial and one for Intermittent—but I only see the Perennial template on the Create Features window. This reminds me that I am using a definition query to show only perennial streams and hide the smaller intermittent streams. I applied this definition query earlier to reduce the number of features shown and declutter the map when I was working with a large area.

While I could switch the definition query to “Type” = ‘Intermittent’ to show only the intermittent streams and hide the perennial ones, the best approach may be to remove the query altogether and show all features again. This way, I can make sure the new features connect properly, since I cannot snap to features that are hidden by a definition query. When creating features, I am also going to be zoomed in closer where it makes sense to draw all the features.

An alternative approach is to create a second streams layer that shows only the intermittent ones, allowing me to keep the original layer’s perennial streams definition query intact. Either way, the bottom line is that I must display intermittent streams and should show the perennial streams as well so I can create features in relation to them.

A definition query cannot be set on a system field while creating features.
When editing, definition queries on ArcGIS system fields, such as OBJECTID, Shape_Area, or Shape_Length, are not supported. As I am working with the streams layer, I later set a definition query on the Shape_Length field to display only streams that are longer than 1000 meters (“Shape_Length” > 1000). Because it is on a system field, I will not be able to create features in that layer. This is because I cannot set a feature template’s default attribute value for a system field, as ArcMap controls those fields and their values cannot be user-defined. Since there is not a way to satisfy that definition query with the template’s default attribute values, no templates in this layer will ever display on the Create Features window using this query.

I should also not attempt this workflow on my own fields. For example, if I have a similar definition query where a field called Stream Length must be greater than 1000 meters, then I must set 1000 or a larger number as the feature template’s default attribute value to make the new features display on the map and the feature template show on the Create Features window. Therefore, every new stream I create will be assigned a constant value of 1000 meters for the Stream Length field, which is not the true length of the feature. I would then have to recalculate the Stream Length field after I created each feature. Definition queries while editing work best on discrete categories, rather than attempting to set up an inequality equation such as this one.

Author maps specifically to be used when editing.
Esri generally recommends building and working with maps that are each designed for a certain ArcMap workflow, such as a map to be used specifically when editing. Depending on the GIS tasks, this means that I may have several map documents referencing one set of data—for example, a visually pleasing map with labels and cartographic effects for creating mapping products, a functional map used when editing, and a simple map for sharing on the web or a mobile device.

When creating a map for editing, I should consider authoring the appropriate layer properties, such as symbology, display expressions, fields, and definition queries. If a definition query is being applied primarily for display purposes, it may require additional work to implement when editing or just may not be suitable for use when creating features. I also need to set up the editing environment, including snapping, editing options, and feature template properties. My editing tasks will be more productive and successful if I prepare my map for editing prior to starting an edit session.

Content for post provided by Rhonda (Editing Team)

Next Article

What’s new in ArcGIS StoryMaps (April 2024)

Read this article