ArcGIS Desktop

  • 文档
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

求解

需要 Network Analyst 许可。

  • 摘要
  • 用法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

摘要

基于网络位置和属性求解网络分析图层问题。

用法

  • 求解失败时,警告和错误消息可提供有关失败原因的有用信息。

  • 运行此工具前,请确保为网络分析图层指定了求解问题所需的所有参数。

语法

Solve_na (in_network_analysis_layer, {ignore_invalids}, {terminate_on_solve_error}, {simplification_tolerance})
参数说明数据类型
in_network_analysis_layer

要进行分析计算的网络分析图层。

Network Analyst Layer
ignore_invalids
(可选)
  • SKIP —求解程序将跳过未定位的网络位置而仅根据有效的网络位置来求解分析图层。如果这些位置位于不可遍历的元素上或有其他错误,求解程序仍会继续求解。如果您知道您的网络位置并不完全正确,但是想对有效的网络位置求解,此选项很有用。
  • HALT —如果存在无效位置,则不执行求解。随后您可对这些无效位置进行调整,然后重新运行分析。
Boolean
terminate_on_solve_error
(可选)
  • TERMINATE —该工具将在求解程序遇到错误时无法执行操作。这是默认设置。使用该选项时,如果工具因求解程序遇到错误而无法执行操作,则不创建任何结果对象。您应通过 ArcPy 对象获取地理处理消息。
  • CONTINUE —即使求解程序遇到错误,该工具也不停止,而是继续执行操作。求解程序返回的所有错误消息都将转换为警告消息。使用该选项时,即使求解程序遇到错误,也始终创建结果对象,并将结果对象的 maxSeverity 属性设置为 1。对结果对象使用 getOutputo 方法(索引值 为1) 可确定求解程序是否成功。
Boolean
simplification_tolerance
(可选)

容差确定输出几何的简化程度。如果已指定了容差,容差必须大于零。可以选择首选单位;默认单位为十进制度。

指定简化容差会减少渲染路径或服务区的时间。但缺点是,简化几何移除了折点,这样会降低以更大比例输出的空间精确度。

由于带两个折点的线不能再简化,所以此参数对单一线段输出的绘制时间没有影响,例如直线路线、 OD 成本矩阵线和位置分配线。

Linear unit

代码示例

求解示例 1(Python 窗口)

使用所有参数执行工具。

arcpy.na.Solve("Route", "HALT", "TERMINATE", "10 Meters")
求解示例 2(工作流)

以下独立 Python 脚本演示了如何使用“求解”工具执行最近设施点分析并将结果保存到图层文件中。

# 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)

环境

  • 当前工作空间

许可信息

  • ArcGIS Desktop Basic: 需要 Network Analyst
  • ArcGIS Desktop Standard: 需要 Network Analyst
  • ArcGIS Desktop Advanced: 需要 Network Analyst

相关主题

  • ArcGIS Network Analyst 扩展模块所使用的算法
  • 网络分析疑难解答
  • 分析工具集概述
  • 前台和后台处理

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明