Skip To Content

Copy Traversed Source Features


Creates two feature classes and a table, which together contain information about the edges, junctions, and turns that are traversed while solving a network analysis layer.

Learn about the output from Copy Traversed Source Features


  • The tool solves the input network analysis layer if it isn't already solved. The analysis layer is re-solved if any changes have been made to the inputs since the last solve.

  • Traversed source features can be generated for the following network analysis layers:

    • Route
    • Service area
    • Closest facility
    • Vehicle routing problem

    Traversed source features cannot be generated for the following layers:

    • OD cost matrix
    • Location-allocation

  • The output junctions feature class not only includes points that represent traversed network junctions, it also includes points that represent the following:

    • Traversed point barriers
    • Entry and exit points of traversed line and polygon barriers
    • Visited stops in a route analysis
    • Visited facilities and the ends of breaks in a service area analysis
    • Visited facilities and incidents in a closest facility analysis
    • Visited orders, depots, and breaks in a vehicle routing problem

    Learn about the output from Copy Traversed Source Features

  • The coordinate system for the output feature classes can be controlled by specifying the Output Coordinate System environment setting or by specifying a feature dataset in a geodatabase as the value for the Output Location parameter. If the Output Coordinate System environment setting is not specified or the Output Location parameter is not a feature dataset, the output feature classes have the same coordinate system as the input network analysis layer.


CopyTraversedSourceFeatures_na (input_network_analysis_layer, output_location, edge_feature_class_name, junction_feature_class_name, turn_table_name)
ParameterExplanationData Type

The network analysis layer from which traversed source features will be copied. If the network analysis layer does not have a valid result, the layer will be solved to produce one.

Network Analyst Layer

The workspace where the output table and two feature classes will be saved.

Workspace; Feature Dataset

The name of the feature class that will contain information about the traversed edge source features. If the solved network analysis layer doesn't traverse any edge features, an empty feature class is created.


The name of the feature class that will contain information about the traversed junction source features, including system junctions and relevant points from the input network analysis layer. If the solved network analysis layer doesn't traverse any junctions, an empty feature class is created.


The name of the table that will contain information about the traversed global turns and turn features that scale cost for the underlying edges. If the solved network analysis layer doesn't traverse any turns, an empty table is created. Since restricted turns are never traversed, they are never included in the output.


Code sample

CopyTraversedSourceFeatures example 1 (Python window)

The following Python window script demonstrates how to use the CopyTraversedSourceFeatures tool to write the traversed edges, junctions, and turns from a Route network analysis layer to feature classes and table in an in-memory workspace."Route", "C:/Data/Output.gdb",
CopyTraversedSourceFeatures example 2 (workflow)

The following stand-alone Python script demonstrates how CopyTraversedSourceFeatures can be used to find the streets that are common to the routes from census tract centroids to the closest fire station. These results help identify which streets are most frequently used emergencies.

# Name:
# Description: The scenario shows how to find the streets that are common to the
#              routes between the closest fire station and the census tract
#              centroids. These streets can be used to identify critical points
#              in case of an emergency.
# Requirements: Network Analyst Extension

#Import system modules
import os
import arcpy
from arcpy import env

    #Check out Network Analyst license if available. Fail if the Network Analyst license is not available.
    if arcpy.CheckExtension("network") == "Available":
        raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
    #Set environment settings
    output_dir = "C:/Data"
    #The NA layer's data will be saved to the workspace specified here
    env.workspace = os.path.join(output_dir, "Output.gdb")
    env.overwriteOutput = True
    env.qualifiedFieldNames = False

    #Set local variables
    input_gdb = "C:/Data/SanFrancisco.gdb"
    output_gdb = "C:/Data/Output.gdb"
    network = os.path.join(input_gdb, "Transportation", "Streets_ND")
    layer_name = "EmergencyRoutes"
    travel_mode = "Driving Time"
    facilities = os.path.join(input_gdb, "Analysis", "FireStations")
    incidents = os.path.join(input_gdb, "Analysis", "TractCentroids")
    edge_frequency = os.path.join(output_gdb, "EdgeFrequency")
    critical_streets = os.path.join(output_gdb, "CriticalStreets")

    #Create a new closest facility analysis layer.
    result_object =,
                                                layer_name, travel_mode,

    #Get the layer object from the result object. The closest facility layer can
    #now be referenced using the layer object.
    layer_object = result_object.getOutput(0)

    #Get the names of all the sublayers within the closest facility layer.
    sublayer_names =
    #Stores the layer names that we will use later
    facilities_layer_name = sublayer_names["Facilities"]
    incidents_layer_name = sublayer_names["Incidents"]

    #Load fire station features as facilities and ensure that they are not
    #located on restricted portions of the network. Use default field mappings
    #and search tolerance, facilities_layer_name, facilities, "",
                          "", exclude_restricted_elements="EXCLUDE")

    #Load tract centroids as incidents and ensure that they are not located on
    #restricted portions of the network. Map the ID field from Tract Centroids
    #as the name for incidents using field mappings
    field_mappings =,
    field_mappings['Name'].mappedFieldName = "ID", incidents_layer_name, incidents,
                          field_mappings, "",

    #Solve the closest facility layer and copy the travered source features to
    #the output geodatabase. Use default names for the output feature
    #classes and table. Retrieve the first output, which is the traversed edges.
    traversed_edges =,

    #Some streets might be traversed by more than one route. Streets traversed
    #by many routes are the most critical emergency routes. Count the number of
    #routes using each street.
    arcpy.analysis.Frequency(traversed_edges, edge_frequency,
                             ["SourceOID", "SourceName"])

    #The resulting edge features from CopyTraversedSourceFeatures may include
    #clipped versions of the original street features because the Closest
    #Facility route only traveled across part of the street feature. Select
    #the complete street features from the original street feature class and
    #copy them to output.
    #Get the full path to the network dataset's streets feature class by
    #describing the network dataset.
    network_desc = arcpy.Describe(network)
    edge_sources = network_desc.edgeSources
    for es in edge_sources:
        if == "streets":
            streets_source = os.path.join(os.path.dirname(network),

    #Select the relevant streets based on overlap with the results from
    streets_layer =,
                                "SHARE_A_LINE_SEGMENT_WITH", traversed_edges)

    #Add the frequency information to the output feature class using JoinField, "ObjectID", edge_frequency,
                               "SourceOID", "FREQUENCY")

    #Save the selected features to disk, critical_streets)

    #Delete the Frequency field from the street feature class, "FREQUENCY")

    print("Script completed successfully")

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print("An error occurred on line %i" % tb.tb_lineno)

Licensing information

  • ArcGIS Desktop Basic: Requires Network Analyst
  • ArcGIS Desktop Standard: Requires Network Analyst
  • ArcGIS Desktop Advanced: Requires Network Analyst

Related topics