描述
基于网络位置和属性求解网络分析图层问题。
使用
- 求解失败时,警告和错误消息可提供有关失败原因的有用信息。 
- 运行此工具前,请确保为网络分析图层指定了求解问题所需的所有参数。 
语法
Solve(in_network_analysis_layer, {ignore_invalids}, {terminate_on_solve_error}, {simplification_tolerance}, {overrides})| 参数 | 说明 | 数据类型 | 
| in_network_analysis_layer | 要进行分析计算的网络分析图层。 | Network Analyst Layer | 
| ignore_invalids (可选) | 
 | Boolean | 
| terminate_on_solve_error (可选) | 
 | Boolean | 
| simplification_tolerance (可选) | 容差确定输出几何的简化程度。如果已指定了容差,容差必须大于零。可以选择首选单位;默认单位为十进制度。 指定简化容差会减少渲染路径或服务区的时间。但缺点是,简化几何移除了折点,这样会降低以更大比例输出的空间精确度。 由于带两个折点的线不能再简化,所以此参数对单一线段输出的绘制时间没有影响,例如直线路线、 OD 成本矩阵线和位置分配线。 | Linear Unit | 
| overrides (可选) | 求解网络分析问题时,指定可影响求解程序行为的其他设置。 需要在 JavaScript 对象表示法 (JSON) 中指定此参数的值。例如,有效值的格式如下:{"overrideSetting1" : "value1", "overrideSetting2" : "value2"}。覆盖设置名称始终以双引号括起。该值可以是数字、布尔值或字符串。 此参数的默认值为无值,表示不覆盖任何求解程序设置。 覆盖是高级设置,应仅在谨慎分析应用设置前后得到的结果之后使用。要获得每个求解程序支持的覆盖设置及其可接受值的列表,请联系 Esri 技术支持。 | String | 
派生输出
| 名称 | 说明 | 数据类型 | 
| output_layer | 已求解的网络分析图层。 | 网络分析图层 | 
| solve_succeeded | 指示求解是否成功的布尔值。 | 布尔型 | 
代码示例
Solve 示例 1(Python 窗口)
使用所有参数执行工具。
arcpy.na.Solve("Route", "HALT", "TERMINATE", "10 Meters")
Solve 示例 2(工作流)
以下独立 Python 脚本演示了如何使用 Solve 工具执行最近设施点分析并将结果保存到图层文件中。
# 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 occurred on line %i" % tb.tb_lineno
    print str(e)
环境
许可信息
- Basic: 需要 Network Analyst
- Standard: 需要 Network Analyst
- Advanced: 需要 Network Analyst