Skip To Content

Add Spatial Query Rule

Summary

Adds a diagram rule that automatically appends new utility network features to the diagrams based on their location relative to the utility 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 that must be run by the database owner of the utility network through a direct connection to the default version. In addition to that requirement, the connected portal account must be the owner of the utility network to perform this operation. This essentially forms two-factor authentication.

Usage

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

  • The utility network features with which the rule works are based on the same feature class; those features are optionally filtered using an SQL query expression.

  • The appended utility network features are based on the same feature class; those features are optionally filtered using an SQL query expression.

Syntax

AddSpatialQueryRule_un (in_utility_network, template_name, is_active, added_features, {overlap_type}, existing_features, {search_distance}, {added_where_clause}, {existing_where_clause}, {description})
ParameterExplanationData Type
in_utility_network

The utility network referencing the diagram template to modify.

Utility Network
template_name

The name of the diagram template to modify.

String
is_active

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

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

The source feature class to which you want to add features

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 one of 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 selected; lines that share a line segment will not.
String
existing_features

The source feature class of the features existing in the diagram from which the spatial query will execute.

Feature Class
search_distance
(Optional)

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.

Utility Network
out_template_name

The name of the network 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_UtilityNetwork = "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_un(input_UtilityNetwork, 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