Returns a Layer or Table object for the designated sublayer or subtable of the specified network analysis layer. This object can be used as input for further analysis.

For example, you can use this method to retrieve the Polygons sublayer of a Service Area analysis layer.


This Python function is similar to the Select Data ModelBuilder tool.

Ältere Versionen:

This function was introduced in ArcGIS Pro 2.7. In earlier software versions, the best way to retrieve a sublayer object of a network analysis layer was to use the listLayers method of the network analysis Layer object using the sublayer's name as a wildcard.


GetNASublayer (network_analyst_layer, naclass_name)

A network analysis layer from which you want to retrieve a sublayer, referenced as a layer object or by its layer name.


The class name for the sublayer or subtable to retrieve.

The following table lists the class names for each network analysis layer type:

Closest Facility

  • Facilities—Facilities
  • Incidents—Incidents
  • CFRoutes—Routes
  • Barriers—Point Barriers
  • PolylineBarriers—Line Barriers
  • PolygonBarriers—Polygon Barriers


  • Facilities—Facilities
  • DemandPoints—Demand Points
  • LALines—Lines
  • Barriers—Point Barriers
  • PolylineBarriers—Line Barriers
  • PolygonBarriers—Polygon Barriers

Origin Destination Cost Matrix

  • Origins—Origins
  • Destinations—Destinations
  • ODLines—Lines
  • Barriers—Point Barriers
  • PolylineBarriers—Line Barriers
  • PolygonBarriers—Polygon Barriers


  • Stops—Stops
  • Routes—Routes
  • Barriers—Point Barriers
  • PolylineBarriers—Line Barriers
  • PolygonBarriers—Polygon Barriers

Service Area

  • Facilities—Facilities
  • SAPolygons—Polygons
  • SALines—Lines
  • Barriers—Point Barriers
  • PolylineBarriers—Line Barriers
  • PolygonBarriers—Polygon Barriers

Vehicle Routing Problem

  • Orders—Orders
  • Depots—Depots
  • Routes—Routes
  • Breaks—Breaks
  • DepotVisits—Depot Visits
  • RouteZones—Route Zones
  • OrderPairs—Order Pairs
  • RouteRenewals—Route Renewals
  • OrderSpecialties—Order Specialties
  • RouteSpecialties—Route Specialties
  • Barriers—Point Barriers
  • PolylineBarriers—Line Barriers
  • PolygonBarriers—Polygon Barriers


A Layer or Table object for the designated sublayer or subtable of the specified network analysis layer.


GetNASublayer example 1

Retrieve the Route Specialties subtable of a Vehicle Routing Problem analysis layer called Tuesday deliveries.

tuesday = datetime.datetime(1900, 1, 2)
layer_name = "Tuesday deliveries"
vrp_layer_object =
    "Streets_ND", layer_name, "Driving Time", 
route_specialties_table =, "RouteSpecialties")
GetNASublayer example 2 (workflow)

The following stand-alone Python script demonstrates how to access sublayers, join input and output layers, and transfer field values from input origins and destinations to the output Lines layer in an OD Cost Matrix analysis workflow.

# Name:
# Description: Find the travel time to the closest hospital from each census
#               tract and join the travel time and hospital name to the input
#               tracts.
# Requirements: Network Analyst Extension

# Import system modules
import datetime
import os
import arcpy

    # 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
    arcpy.env.workspace = os.path.join(output_dir, "Output.gdb")
    arcpy.env.overwriteOutput = True

    # Set inputs and outputs
    input_gdb = "C:/Data/SanFrancisco.gdb"
    network = os.path.join(input_gdb, "Transportation", "Streets_ND")
    origins = os.path.join(input_gdb, "Analysis", "TractCentroids")
    destinations = os.path.join(input_gdb, "Analysis", "Hospitals")
    output_features = "TractCentroids_withOD"

    # Define some OD cost matrix analysis settings
    layer_name = "HospitalsOD"
    # User settings for driving
    travel_mode = "Driving Time"
    # Calculate the total distance, even though the analysis is optimizing time
    accumulate_attributes = ["Meters"]
    # Find only the closest hospital
    num_hospitals_to_find = 1
    # Set the time of day for the analysis to 6PM on a generic Monday.
    start_time = datetime.datetime(1900, 1, 1, 18, 0, 0)
    # Don't output line shapes (output Lines will still list travel times)
    out_lines = "NO_LINES"

    # Create a new OD cost matrix layer.
    result_object =, layer_name,
                    time_of_day=start_time, line_shape=out_lines, 

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

    # Get the names of all the sublayers within the OD layer.
    sublayer_names =
    # Store the layer names for later use
    origins_layer_name = sublayer_names["Origins"]
    destinations_layer_name = sublayer_names["Destinations"]

    # The input census tract data has a unique ID field that can be transferred
    # to the analysis layer. Add the field, and then use field mapping to
    # transfer the values., origins_layer_name,
                                                        "Tract_ID", "TEXT")
    field_mappings =,
    field_mappings["Tract_ID"].mappedFieldName = "ID"

    # Load the census tracts as origins., origins_layer_name, origins,
                            field_mappings, "")

    # Map the input hospital NAME field to a new Hospital_Name field in
    # Destinations, destinations_layer_name,
                                                        "Hospital_Name", "TEXT")
    field_mappings =,
    field_mappings["Hospital_Name"].mappedFieldName = "NAME"

    # Load the hospitals as desinations., destinations_layer_name, destinations,
                            field_mappings, "")

    # Solve the OD layer

    # Get sublayers
    origins_sublayer =, "Origins")
    destinations_sublayer =, "Destinations")
    lines_sublayer =, "ODLines")

    # Use the JoinField tool to transfer OD Cost Matrix information to the
    # output feature class
    # Transfer the tract ID from the input Origins to the output Lines, "OriginID",
                                    origins_sublayer, "ObjectID", "Tract_ID")
    # Transfer the hospital name from the input Destinations to the output Lines, "DestinationID",
                            destinations_sublayer, "ObjectID", "Hospital_Name")
    # Transfer fields of interest (hospital name, impedance attribute, and other
    # accumulated costs) from the output Lines to a copy of the input census
    # tracts feature class using the Tract_ID field
    # Determine the impedance attribute
    solver_props =
    impedance = solver_props.impedance
    output_impedance_fieldname = "Total_" + impedance
    fields_to_transfer = ["Hospital_Name", output_impedance_fieldname]
    for field in accumulate_attributes:
        fields_to_transfer.append("Total_" + field), output_features), "ID",
                                lines_sublayer, "Tract_ID", fields_to_transfer)

    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)