Populate Alternate ID Fields (Network Analyst)

Summary

Creates and populates additional fields on the turn feature classes that reference the edges by alternate IDs. The alternate IDs allow for another set of IDs that can help maintain the integrity of the turn features in case the source edges are being edited.

Usage

  • The tool creates and populates new fields called AltID<n>, where n is the maximum number of edges per turn. For example, for two-edge turn feature classes, the tool creates and populates fields called AltID1 and AltID2.

  • Shapefiles do not have a persistent unique identifier, unlike the geodatabase's ObjectID field. Alternate IDs can avoid the ID shift problem commonly encountered when working with turn feature classes in a shapefile workspace.

  • If the edge feature sources do not have an alternate ID field, for example, a unique identifier provided by a data vendor, then you must create and populate such a field so that it can used by this tool to reference the turn features.

Syntax

arcpy.na.PopulateAlternateIDFields(in_network_dataset, alternate_ID_field_name)
ParameterExplanationData Type
in_network_dataset

The network dataset whose turn feature classes are to receive alternate ID fields. The fields will be created on all of the turn feature classes added as a turn source to the network dataset.

Network Dataset Layer
alternate_ID_field_name

The name of the alternate ID field on the edge feature sources of the network dataset. All edge feature sources referenced by turns must have the same name for the alternate ID field.

String

Derived Output

NameExplanationData Type
out_network_dataset

The updated network dataset.

Network Dataset Layer

Code sample

PopulateAlternateIDFields example 1 (Python window)

Execute the tool using all parameters.

network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.PopulateAlternateIDFields(network, "ID")
PopulateAlternateIDFields example 2 (stand-alone script)

The following Python script demonstrates how to use the PopulateAlternateIDFields tool in a stand-alone script.

# Name: PopulateAlternateIDFields_ex02.py
# Description: Create and populate the alternate ID fields for all turn sources
#              in the network dataset.
# Requirements: Network Analyst Extension

#Import system modules
import arcpy
from arcpy import env

#Set environment settings
env.workspace = "C:/data/SanFrancisco.gdb/Transportation"

#Set local variables
inNetworkDataset = "Streets_ND"
altIDFieldName = "ID"

#Populate alternate IDs on all turn sources in the network dataset
arcpy.PopulateAlternateIDFields_na(inNetworkDataset,altIDFieldName)

print("Script completed successfully.")

Environments

Licensing information

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

Related topics