Nearest Neighbor properties

サマリー

The properties below are returned by the nearestNeighbor object when using Describe on a utility network.

Learn more about filtering what is traced

プロパティ

プロパティ説明データ タイプ
costNetworkAttributeName
(読み取り専用)

If the filter nearest function is being used, this is the name of the network attribute that is being used to calculate the cost. If the filter nearest function is not being used, this property returns an empty string.

String
count
(読み取り専用)

If the filter nearest function is being used, this is the value of the number of features to be returned. If the filter nearest function is not being used, this property returns a -1 value.

Integer
nearestAssets
(読み取り専用)

The nearestAssets object. If the filter nearest function is being used, these are the asset groups and asset types that will be returned. If the filter nearest function is not being used, this property returns an empty list.

Object
nearestCategories
(読み取り専用)

If the filter nearest function is being used, these are the names of the categories that will be returned. If the filter nearest function is not being used, this property returns an empty list.

String

コードのサンプル

Utility network nearest neighbor and nearest asset properties example (stand-alone script)

This stand-alone Python script prints a report of some utility network properties.

# Import required modules
import arcpy

# Describe functions on a Utility Network
UN = "C:\\Projects\\MyProject\\unowner.sde\\Naperville.UNOWNER.Naperville\\Naperville.UNOWNER.Naperville" 
d = arcpy.Describe(UN)

# Domain Network properties
domnets = d.domainNetworks

# For each domain network in the utility network
for dom in domnets:
    print(f"Domain Network Name: {dom.domainNetworkName}")
    
    # For each tier in the domain network
    for tier in dom.tiers:
        print(f"Tier Name: {tier.name}")
                
        # Update Subnetwork Trace Configuration Properties     
        ust = tier.updateSubnetworkTraceConfiguration

        # Nearest Neighbor Properties
        print(" - Nearest Neighbor Properties - ")
        nn = ust.nearestNeighbor
        # Try to get these properties if the exist, else, print the empty list
        try:
            print(f"Count: {nn.count}")
            print(f"Cost Network Attribute Name: {nn.costNetworkAttributeName}")
            print(f"Nearest Categories: {nn.nearestCategories} \n")
            print(f" - Nearest Asset Properties - ")
            for nsta in nn.nearestAssets:
                try:
                    print(f"Network Source ID: {nsta.networkSourceID}")
                    print(f"Asset Group Code: {nsta.assetGroupCode}")
                    print(f"Asset Type Code: {nsta.assetTypeCode} \n")
                except:
                    print("Skipped nearest assets properties. \n")
        except:
            print("Skipped nearest neighbor properties. \n")