ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Solve

Available with Network Analyst license.

  • Summary
  • Usage
  • Syntax
  • Code Sample
  • Environments
  • Licensing Information

Summary

Solves the network analysis layer problem based on its network locations and properties.

Usage

  • When the solve fails, the warning and error messages provide useful information about the reasons for the failure.

  • Be sure to specify all the parameters on the network analysis layer that are necessary to solve the problem before running this tool.

Syntax

Solve_na (in_network_analysis_layer, {ignore_invalids}, {terminate_on_solve_error}, {simplification_tolerance})
ParameterExplanationData Type
in_network_analysis_layer

The network analysis layer on which the analysis will be computed.

Network Analyst Layer
ignore_invalids
(Optional)
  • SKIP —The solver will skip over network locations that are unlocated and solve the analysis layer from valid network locations only. It will also continue solving if locations are on nontraversable elements or have other errors. This is useful if you know your network locations are not all correct, but you want to solve with the network locations that are valid.
  • HALT —Do not solve if there are invalid locations. You can then correct these and re-run the analysis.
Boolean
terminate_on_solve_error
(Optional)
  • TERMINATE —The tool will fail to execute when the solver encounters an error. This is the default. When you use this option, the result object is not created when the tool fails to execute due to a solver error. You should obtain the geoprocessing messages from the ArcPy object.
  • CONTINUE —The tool will not fail and continue execution even when the solver encounters an error. All of the error messages returned by the solver will be converted to warning messages. When you use this option, the result object is always created and the maxSeverity property of the result object is set to 1 even when the solver encounters an error. Use the getOutput method of the result object with an index value of 1 to determine if the solve was successful.
Boolean
simplification_tolerance
(Optional)

The tolerance that determines the degree of simplification for the output geometry. If a tolerance is specified, it must be greater than zero. You can choose a preferred unit; the default unit is decimal degrees.

Specifying a simplification tolerance tends to reduce the time it takes to render routes or service areas. The drawback, however, is that simplifying geometry removes vertices, which may lessen the spatial accuracy of the output at larger scales.

Because a line with only two vertices cannot be simplified any further, this parameter has no effect on drawing times for single-segment output, such as straight-line routes, OD cost matrix lines, and location-allocation lines.

Linear unit

Code Sample

Solve example 1 (Python window)

Execute the tool using all the parameters.

arcpy.na.Solve("Route", "HALT", "TERMINATE", "10 Meters")
Solve example 2 (workflow)

The following stand-alone Python script demonstrates how the Solve tool can be used to perform a closest facility analysis and save results to a layer file.

# Name: Solve_Workflow.py
# Description: Solve a closest facility analysis to find the closest warehouse 
#              from the store locations and save the results to a layer file on 
#              disk.
# Requirements: Network Analyst Extension 

#Import system modules
import arcpy
from arcpy import env

try:
    #Check out the Network Analyst extension license
    arcpy.CheckOutExtension("Network")

    #Set environment settings
    env.workspace = "C:/data/Paris.gdb"
    env.overwriteOutput = True
    
    #Set local variables
    inNetworkDataset = "Transportation/ParisMultimodal_ND"
    outNALayerName = "ClosestWarehouse"
    impedanceAttribute = "Drivetime"
    accumulateAttributeName = ["Meters"]
    inFacilities = "Analysis/Warehouses"
    inIncidents = "Analysis/Stores"
    outLayerFile = "C:/data/output" + "/" + outNALayerName + ".lyr"
    
    #Create a new closest facility analysis layer. Apart from finding the drive 
    #time to the closest warehouse, we also want to find the total distance. So
    #we will accumulate the "Meters" impedance attribute.
    outNALayer = arcpy.na.MakeClosestFacilityLayer(inNetworkDataset,outNALayerName,
                                                   impedanceAttribute,"TRAVEL_TO",
                                                   "",1, accumulateAttributeName,
                                                   "NO_UTURNS")
    
    #Get the layer object from the result object. The closest facility layer can 
    #now be referenced using the layer object.
    outNALayer = outNALayer.getOutput(0)
    
    #Get the names of all the sublayers within the closest facility layer.
    subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
    #Stores the layer names that we will use later
    facilitiesLayerName = subLayerNames["Facilities"]
    incidentsLayerName = subLayerNames["Incidents"]
    
    #Load the warehouses as Facilities using the default field mappings and 
    #search tolerance
    arcpy.na.AddLocations(outNALayer, facilitiesLayerName, inFacilities, "", "")
    
    #Load the Stores as Incidents. Map the Name property from the NOM field
    #using field mappings
    fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, incidentsLayerName)
    fieldMappings["Name"].mappedFieldName = "NOM"
    arcpy.na.AddLocations(outNALayer, incidentsLayerName, inIncidents,
                          fieldMappings,"")
    
    #Solve the closest facility layer
    arcpy.na.Solve(outNALayer)
    
    #Save the solved closest facility layer as a layer file on disk with 
    #relative paths
    arcpy.management.SaveToLayerFile(outNALayer,outLayerFile,"RELATIVE")
    
    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
    print str(e)

Environments

  • Current Workspace

Licensing Information

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

Related Topics

  • Algorithms used by the ArcGIS Network Analyst extension
  • Troubleshooting network analyses
  • An overview of the Analysis toolset
  • Foreground and background processing
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal