Add Spatial Query Rule (Network Diagram)

Summary

Adds a diagram rule that automatically appends new network features to the diagrams based on their location relative to the network features currently represented in the diagram.

Learn more about using spatial query rules to build network diagrams

Caution:

This tool is a configuration and administration tool.

Note:

This tool impacts the consistency of any existing diagrams based on the input diagram template. All of the existing diagrams become inconsistent and open with a consistency warning icon May be inconsistent until they are updated.

Usage

  • This tool is not supported when working with a utility network or trace network service. You must use either a utility network or trace network in a file or mobile geodatabase, or a database connection to a utility network or trace network in an enterprise geodatabase. When working with an enterprise geodatabase the following are requirements:

  • The Spatial Query rule is used to detect new network features based on their location relative to network features that currently exist in the diagram, and append the newly detected features to the network diagram.

  • The network features with which the rule works are based on the same feature class, and those features can be filtered using an SQL query expression.

  • The appended network features are based on the same feature class, and those features can be filtered using an SQL query expression.

Parameters

LabelExplanationData Type
Input Network

The utility network or trace network containing the diagram template that will be modified.

Utility Network; Trace Network
Input Diagram Template

The name of the diagram template that will be modified.

String
Active

Specifies whether the rule will be active when generating and updating diagrams based on the specified template.

  • Checked—The added rule will become active during the generation and update of any diagrams based on the input template. This is the default.
  • Unchecked—The added rule will not become active during the generation or update of any diagrams based on the input template.

Boolean
Add Features

The source feature class to which features will be added.

Feature Class
Relationship
(Optional)

Specifies the spatial relationship between the features.

  • Intersect The features in the Add Features source feature class will be appended to the diagram if they intersect one of the Existing Features. This is the default.
  • Within a distance The features in the Add Features source feature class will be appended to the diagram if they are within the specified distance (using Euclidean distance) of one of the Existing Features. Use the Search Distance parameter to specify the distance.
  • Contains | Is contained of The features in the Add Features source feature class will be appended to the diagram if they contain features from or are contained in the Existing Features.
  • Within The features in the Add Features source feature class will be appended to the diagram if they are within Existing Features.
  • Boundary touches The features in the Add Features source feature class will be appended to the diagram if they have a boundary that touches one of the Existing Features. When the Existing Features are lines or polygons, the boundary of the Add Features input feature can only touch the boundary of one of the Existing Features, and no part of the input feature can cross the boundary of one of the Existing Features.
  • Share a line segment with The features in the Add Features source feature class will be appended to the diagram if they share a line segment with one of the Existing Features. The added and existing features must be line or polygon.
  • Crossed by the outline of The features in the Add Features source feature class will be appended to the diagram if they are crossed by the outline of one of the Existing Features. The added and existing features must be lines or polygons. If polygons are used for the Existing Features, the polygon's boundary (line) will be used. Lines that cross at a point will be appended; lines that share a line segment will not.
String
Existing Features

The source feature class on which the spatial query will execute.

Feature Class
Search Distance
(Optional)

The distance between features in the Existing Features parameter and features in the Add Features parameter. This parameter is only valid if the Relationship parameter is set to Intersect, Within a distance, Contains, or Within

Linear Unit
Added Features Query Definition
(Optional)

The SQL query that will be used to filter the features to be added to the diagram. Without an SQL query, the features based on the specified source class that are spatially related to the specified existing features will be appended to the diagram.

SQL Expression
Existing Features Query Definition
(Optional)

The SQL query that will be used to filter the features existing in the diagram. Without an SQL query, the features based on the specified source class that exist in the diagram will be considered.

SQL Expression
Description
(Optional)

The description of the rule.

String

Derived Output

LabelExplanationData Type
Output Network

The updated utility network or trace network.

Utility Network; Trace Network
Output Diagram Template

The name of the diagram template.

String

arcpy.nd.AddSpatialQueryRule(in_utility_network, template_name, is_active, added_features, {overlap_type}, existing_features, {search_distance}, {added_where_clause}, {existing_where_clause}, {description})
NameExplanationData Type
in_utility_network

The utility network or trace network containing the diagram template that will be modified.

Utility Network; Trace Network
template_name

The name of the diagram template that will be modified.

String
is_active

Specifies whether the rule will be enabled when generating and updating diagrams based on the specified template.

  • ACTIVEThe added rule will become enabled during the generation and update of any diagrams based on the input template. This is the default.
  • INACTIVEThe added rule will not become enabled during the generation or update of any diagrams based on the input template.
Boolean
added_features

The source feature class to which features will be added.

Feature Class
overlap_type
(Optional)

The spatial relationship to be evaluated.

  • INTERSECT The features in the added_features source feature class will be appended to the diagram if they intersect one of the existing_features. This is the default.
  • WITHIN_A_DISTANCE The features in the added_features source feature class will be appended to the diagram if they are within the specified distance (using Euclidean distance) of one of the existing_features. Use the search_distance parameter to specify the distance.
  • CONTAINS The features in the added_features source feature class will be appended to the diagram if they contain features from or are contained in the existing_features.
  • WITHIN The features in the added_features source feature class will be appended to the diagram if they are within existing_features.
  • BOUNDARY_TOUCHES The features in the added_features source feature class will be appended to the diagram if they have a boundary that touches one of the existing_features. When the existing_features are lines or polygons, the boundary of the added_features can only touch the boundary of one of the existing_features, and no part of the input feature can cross the boundary of one of the existing_features.
  • SHARE_A_LINE_SEGMENT_WITH The features in the added_features source feature class will be appended to the diagram if they share a line segment with one of the existing_features. The added and existing features must be line or polygon.
  • CROSSED_BY_THE_OUTLINE_OF The features in the added_features source feature class will be appended to the diagram if they are crossed by the outline of one of the existing_features. The added and existing features must be lines or polygons. If polygons are used for the existing_features, the polygon's boundary (line) will be used. Lines that cross at a point will be appended; lines that share a line segment will not.
String
existing_features

The source feature class on which the spatial query will execute.

Feature Class
search_distance
(Optional)

The distance between features in the existing_features parameter and features in the added_features parameter. This parameter is only valid if the overlap_type parameter is set to INTERSECT, WITHIN_A_DISTANCE, CONTAINS, or WITHIN

Linear Unit
added_where_clause
(Optional)

The SQL query that will be used to filter the features to be added to the diagram. Without an SQL query, the features based on the specified source class that are spatially related to the specified existing features will be appended to the diagram.

SQL Expression
existing_where_clause
(Optional)

The SQL query that will be used to filter the features existing in the diagram. Without an SQL query, the features based on the specified source class that exist in the diagram will be considered.

SQL Expression
description
(Optional)

The description of the rule.

String

Derived Output

NameExplanationData Type
out_utility_network

The updated utility network or trace network.

Utility Network; Trace Network
out_template_name

The name of the diagram template.

String

Code sample

AddSpatialQueryRule example (stand-alone script)

Add a Spatial Query rule to the MyTemplate1 template to systematically add all subtransmission lines that intersect substations in the generated diagrams.

import arcpy
input_Network = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.Electric"
input_DistributionLine = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.ElectricDistributionLine"
input_StructureBoundary = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.ElectricStructureBoundary"

input_DiagramTemplate = "MyTemplate1"

arcpy.AddSpatialQueryRule_nd(input_Network, input_DiagramTemplate, 
                             'ACTIVE', input_DistributionLine, 'INTERSECT',
                             input_StructureBoundary, None, 'ASSETGROUP=6', 
                             'ASSETGROUP=3')

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics