Skip To Content



Returns a Network Analyst solver properties object based on the type of the network analysis layer specified as the argument. The solver properties object is used to update the analysis properties for the layer.


GetSolverProperties acts as the main entry point when modifying the analysis properties of a network analysis layer. It returns a separate solver properties object based on the network analysis layer. There are five types of solver properties objects: RouteSolverProperties, ClosestFacilitySolverProperties, ServiceAreaSolverProperties, ODCostMatrixSolverProperties, and LocationAllocationSolverProperties. Each solver properties object provides read/write access to the analysis properties specific to a network analysis layer.


GetSolverProperties (network_analyst_layer)
ParameterExplanationData Type

A variable that references a Layer object obtained from a network analysis layer. It can be derived from existing layers in a map document or by specifying the catalog path to the network analysis layer file as an argument to the Layer class. The isNetworkAnalystLayer property on the Layer object can be used to identify whether a given Layer object is a network analysis layer.

Return Value
Data TypeExplanation

A solver properties object corresponding to the type of the network analysis layer.

Code sample

GetSolverProperties example

This example shows how to use GetSolverProperties to access a network analysis layer's solver properties object and how to use that solver properties object to update analysis settings.

# Name:
# Description: Generate 3-minute service areas around fire stations at several
#               times of day to compare coverage differences due to varying
#               traffic conditions. Use GetSolverProperties to access the
#               Service Area layer's solver properties object, and update the
#               time of day property prior to each solve.
# Requirements: Network Analyst Extension

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

    #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

    #Set local variables
    input_gdb = "C:/Data/SanFrancisco.gdb"
    network = os.path.join(input_gdb, "Transportation", "Streets_ND")
    layer_name = "FireStationCoverage"
    out_featureclass = os.path.join(output_dir, "Output.gdb",
    travel_mode = "Driving Time"
    facilities = os.path.join(input_gdb, "Analysis", "FireStations")
    times_of_day = [datetime.datetime(2014, 9, 25, 7, 0, 0),
                    datetime.datetime(2014, 9, 25, 12, 30, 0),
                    datetime.datetime(2014, 9, 25, 17, 30, 0),
                    datetime.datetime(2014, 9, 25, 21, 0, 0)]

    #Create a new service area layer.
    result_object =, layer_name,
                                                travel_mode, "FROM_FACILITIES",
                                                [3], polygon_detail="HIGH",

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

    #Get the names of all the sublayers within the service area layer.
    sublayer_names =
    #Stores the layer names that we will use later
    facilities_layer_name = sublayer_names["Facilities"]
    polygons_layer_name = sublayer_names["SAPolygons"]

    #The input data has a field for FireStationID that we want to transfer to
    #our analysis layer. Add the field, and then use field mapping to transfer
    #the values., facilities_layer_name,
                                                    "FireStationID", "TEXT")
    field_mappings =,
    field_mappings["FireStationID"].mappedFieldName = "FireStationID"

    #Load the fire stations as facilities., facilities_layer_name, facilities,
                            field_mappings, "")

    # Add fields to the output Polygons sublayer for later use., polygons_layer_name,
                                        "FireStationID", "TEXT"), polygons_layer_name,
                                        "TimeOfDay", "TEXT")

    #Get sublayers to work with later
    facilities_sublayer = layer_object.listLayers(facilities_layer_name)[0]
    polygons_sublayer = layer_object.listLayers(polygons_layer_name)[0]

    #Get the Service Area Layer's solver properties. This can be used to
    #set individual properties later without re-creating the layer.
    solver_properties =

    #Solve the Service Area for each time of day in the time list
    for t in times_of_day:

        print("Calculating service area for time of day: ", t)

        #Use the solver properties to set the time of day for the solve
        solver_properties.timeOfDay = t

        #Solve the service area layer

        #Transfer the FireStationID field from the input Facilities to the
        #output Polygons, "FacilityID",
                                        facilities_sublayer, "ObjectID")
        #The joined fields are qualified by the feature class name of the joined
        #table, so determine the feature class names
        field_qualifier_pol = os.path.basename(polygons_sublayer.dataSource)
        target_field_name = "%s.FireStationID" % field_qualifier_pol
        field_qualifier_fac = os.path.basename(facilities_sublayer.dataSource)
        expression = "!%s.FireStationID!" % field_qualifier_fac, target_field_name,
                                        expression, "PYTHON")

        #Populate the TimeOfDay field in the output feature class
        expression = '"' + str(t) + '"', "TimeOfDay",
                                            expression, "PYTHON")

        #Append the polygons to the output feature class. If this was the first
        #solve, create the feature class.
        if not arcpy.Exists(out_featureclass):
  , out_featureclass)
  , out_featureclass)

    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 occured on line %i" % tb.tb_lineno)