ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • ArcGIS Pro
  • ArcMap
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

  • ArcGIS Pro
  • ArcMap
Esri
English
  • English
  • Deutsch
  • Español
  • Français
  • 日本語
  • Русский
  • 简体中文
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块
  • 基础工具
  • 工具参考
  • Network Analyst 工具箱
  • 分析工具集
  • 返回顶部
  • Network Analyst 工具箱概述
  • Network Analyst 工具箱许可
  • Network Analyst 工具箱历史
  • 分析工具集

    • 分析工具集概述
    • 向分析图层添加字段
    • 添加位置
    • 计算位置
    • 复制遍历的源要素
    • 描述
    • 创建最近设施点图层
    • 创建位置分配图层
    • 创建 OD 成本矩阵图层
    • 创建路径图层
    • 创建服务区图层
    • 创建车辆配送图层
    • 求解
    • 更新分析图层属性参数
    • 分析工具集的概念

    网络数据集工具集

    • 网络数据集工具集概述
    • 构建网络
    • 融合网络
    • 构建网络数据集图层
    • 通过模板创建网络数据集
    • 通过网络数据集创建模板
    • 网络数据集工具集概念

    服务器工具集

    • 服务器工具集概述
    • 查找最近设施点
    • 查找路径
    • 生成起点-目的地成本矩阵
    • 生成服务区
    • 求解位置分配
    • 求解车辆配送问题
    • 更新交通流量数据
    • 更新交通事件点
    • 服务器工具集的概念

    转弯要素类工具集

    • 转弯要素类工具集概述
    • 创建转弯要素类
    • 增加最大边数
    • 填充备用 ID 字段
    • 转弯表至转弯要素类
    • 按备用 ID 字段更新
    • 按几何更新

    创建路径图层

    此 ArcGIS 10.7 文档已 存档,并且不再对其进行更新。 其中的内容和链接可能已过期。 请参阅最新文档。
    • 描述
    • 使用
    • 语法
    • 代码示例
    • 环境
    • 许可信息

    描述

    创建路径网络分析图层并设置其分析属性。路径分析图层可用于根据指定的网络成本确定一组网络位置之间的最佳路径。

    使用

    • 通过此工具创建分析图层后,您可以使用添加位置工具向图层中添加网络分析对象;使用求解工具来求解分析;以及使用保存至图层文件工具将结果保存到磁盘中。

    • 在地理处理模型中使用此工具时,如果模型作为工具来运行,则必须将输出网络分析图层创建为模型参数;否则,输出图层将无法添加到地图内容中。

    语法

    MakeRouteLayer(in_network_dataset, out_network_analysis_layer, impedance_attribute, {find_best_order}, {ordering_type}, {time_windows}, {accumulate_attribute_name}, {UTurn_policy}, {restriction_attribute_name}, {hierarchy}, {hierarchy_settings}, {output_path_shape}, {start_date_time})
    参数说明数据类型
    in_network_dataset

    将在其中执行路径分析的网络数据集。

    Network Dataset Layer
    out_network_analysis_layer

    要创建的路径网络分析图层的名称。

    String
    impedance_attribute

    分析过程中用作阻抗的成本属性。

    String
    find_best_order
    (可选)
    • FIND_BEST_ORDER —将重新排序停靠点以查找最佳路径。此选项将路径分析由最短路径问题变为流动推销员问题 (TSP)。
    • USE_INPUT_ORDER —将按照输入顺序访问停靠点。这是默认设置。
    Boolean
    ordering_type
    (可选)

    当使用 FIND_BEST_ORDER 时,将指定停靠点的顺序。

    • PRESERVE_BOTH —按输入顺序保留第一个和最后一个停靠点作为路径中相应的第一个和最后一个停靠点。
    • PRESERVE_FIRST —按输入顺序保留第一个停靠点作为路径中相应的第一个停靠点,而最后一个停靠点可以被重新排序。
    • PRESERVE_LAST —按输入顺序保留最后一个停靠点作为路径中相应的最后一个停靠点,而第一个停靠点可以被重新排序。
    • PRESERVE_NONE —第一个和最后一个停靠点都可以被重新排序。
    String
    time_windows
    (可选)

    指定是否在停靠点处使用时间窗。

    • USE_TIMEWINDOWS —路径将在停靠点处使用时间窗。如果在时间窗之前到达停靠点,则在时间窗打开前将会有一段等待时间。如果在时间窗之后到达停靠点,将会出现时间窗冲突。当计算路径时,最小阻抗抵消了总的时间窗冲突。仅当阻抗使用时间单位时此选项才可用。
    • NO_TIMEWINDOWS —路径将在停靠点处忽略时间窗。这是默认设置。
    Boolean
    accumulate_attribute_name
    [accumulate_attribute_name,...]
    (可选)

    分析过程中要累积的成本属性的列表。这些累积属性仅供参考;求解程序仅使用阻抗属性参数所指定的成本属性来计算路径。

    对于每个累积的成本属性,均会向求解程序所输出的路径中添加一个 Total_[阻抗] 属性。

    String
    UTurn_policy
    (可选)

    交汇点的 U 形转弯策略。允许 U 形转弯表示求解程序可以在交汇点处转向并沿同一街道往回行驶。考虑到交汇点表示街道交叉路口和死角,不同的车辆可以在某些交汇点转弯,而在其他交汇点则不行 - 这取决于交汇点是交叉路口还是死角。为适应此情况,U 形转弯策略参数由连接到交汇点的边数隐性指定,这称为交汇点价。此参数可接受的值如下所列;每个值的后面是根据交汇点价对其含义的描述。

    • ALLOW_UTURNS —无论在交汇点处有几条连接的边,均允许 U 形转弯。这是默认值。
    • NO_UTURNS —在所有交汇点处均禁止 U 形转弯,不管交汇点原子价如何。不过请注意,即使已选择该设置,在网络位置处仍允许 U 形转弯;但是也可以通过设置个别网络位置的 CurbApproach 属性来禁止 U 形转弯。
    • ALLOW_DEAD_ENDS_ONLY —除仅有一条相邻边的交汇点(死角)外,其他交汇点均禁止 U 形转弯。
    • ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY —在恰好有两条相邻边相遇的交汇点处禁止 U 形转弯,但是交叉点(三条或三条以上相邻边的交汇点)和死角(仅有一条相邻边的交汇点)处允许。通常,网络在路段中间有多余的交汇点。此选项可防止车辆在这些位置出现 U 形转弯。

    如果您需要定义更加精确的 U 形转弯策略,可以考虑在网络成本属性中添加一个通用转弯延迟赋值器,或者如果存在的话,调整其设置,并特别注意反向转弯的配置。还要考虑设置网络位置的 CurbApproach 属性。

    String
    restriction_attribute_name
    [restriction_attribute_name,...]
    (可选)

    分析过程中要应用的限制属性的列表。

    String
    hierarchy
    (可选)
    • USE_HIERARCHY — 使用等级属性进行分析。使用等级的结果是,求解程序更偏好高等级的边而不是低等级的边。分等级求解的速度更快,并且可用于模拟驾驶员在可能的情况下选择在高速公路而非地方道路上行驶(即使行程可能更远)的偏好。只有输入网络数据集具有等级属性时,此选项才有效。
    • NO_HIERARCHY —不使用等级属性进行分析。如果不使用等级属性,则会为网络数据集生成精确的路径。

    如果未在用于执行分析的网络数据集中定义等级属性,该参数将不可用。在这种情况下,使用 "#" 作为参数值。

    Boolean
    hierarchy_settings
    (可选)

    旧版本:

    在版本 10 之前,可使用此参数将网络数据集中建立的默认等级范围更改为其他范围以用于分析。而版本 10 中不再支持此参数,并且应将其指定为空字符串。如果要更改等级范围以进行分析,请更新网络数据集中的默认等级范围。

    Network Analyst Hierarchy Settings
    output_path_shape
    (可选)

    为分析所输出的路径要素指定形状类型。

    • TRUE_LINES_WITH_MEASURES —输出路径将具有基础网络源的精确形状。而且,输出还包括线性参考的路径测量值。测量值从第一个停靠点增加并将记录到达指定位置的累积阻抗。
    • TRUE_LINES_WITHOUT_MEASURES —输出路径将具有基础网络源的精确形状。
    • STRAIGHT_LINES —输出路径形状为两个停靠点之间的一条直线。
    • NO_LINES —将不会为输出路径生成任何形状。

    无论选择何种输出形状类型,最佳路径始终由网络阻抗(而非欧氏距离)决定。只是对路径形状的表现不同,而对网络进行的基础遍历则相同。

    String
    start_date_time
    (可选)

    指定路径的开始日期和时间。路径开始时间通常用于查找阻抗属性随当日时间变化的路径。例如,开始时间 7 a.m. 可用于查找被认为是高峰时段流量的路径。此参数的默认值为 8:00 a.m.。可将日期和时间指定为 10/21/05 10:30 AM。如果路径跨越多天,则仅指定开始时间,并使用当前日期。

    可使用以下日期来指定一周中的每一天,而无需使用特定的日期:

    • 今天 - 12/30/1899
    • 星期日 - 12/31/1899
    • 星期一 - 1/1/1900
    • 星期二 - 1/2/1900
    • 星期三 - 1/3/1900
    • 星期四 - 1/4/1900
    • 星期五 - 1/5/1900
    • 星期六 - 1/6/1900
    例如,要指定行程从星期二 5:00 p.m. 开始,则请将该参数值指定为 1/2/1900 5:00 PM。

    求解结束后,在输出路径中填充路径的开始时间与结束时间。也会在生成方向时使用这些开始时间和结束时间。

    Date

    派生输出

    名称说明数据类型
    output_layer

    新创建的网络分析图层。

    网络分析图层

    代码示例

    MakeRouteLayer 示例 1(Python 窗口)

    仅使用必需参数执行此工具。

    network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
    arcpy.na.MakeRouteLayer(network, "WorkRoute", "TravelTime")
    
    MakeRouteLayer 示例 2(Python 窗口)

    使用所有参数执行此工具。

    network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
    arcpy.na.MakeRouteLayer(network, "InspectionRoute", "TravelTime",
                            "FIND_BEST_ORDER", "PRESERVE_BOTH", "USE_TIMEWINDOWS",
                            ["Meters", "TravelTime"],
                            "ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY", ["Oneway"],
                            "USE_HIERARCHY", "", "TRUE_LINES_WITH_MEASURES",
                            "1/1/1900 9:00 AM")
    
    MakeRouteLayer 示例 3(工作流)

    以下独立 Python 脚本演示了如何使用 MakeRouteLayer 工具查找访问地理编码停靠点位置的最佳路径。

    # Name: MakeRouteLayer_Workflow.py
    # Description: Find a best route to visit the stop locations and save the 
    #              route to a layer file. The stop locations are geocoded from a 
    #              text file containing the addresses.
    # 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/SanFrancisco.gdb"
        env.overwriteOutput = True
        
        #Set local variables
        inNetworkDataset = "Transportation/Streets_ND"
        outNALayerName = "BestRoute"
        impedanceAttribute = "TravelTime"
        inAddressLocator = "SanFranciscoLocator"
        inAddressTable = "C:/data/StopAddresses.csv"
        inAddressFields = "Street Address VISIBLE NONE"
        outStops = "GeocodedStops"
        outLayerFile = "C:/data/output" + "/" + outNALayerName + ".lyr"
        
        #Create a new Route layer. For this scenario, the default value for all the
        #remaining parameters statisfies the analysis requirements
        outNALayer = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName,
                                             impedanceAttribute)
        
        #Get the layer object from the result object. The route layer can now be
        #referenced using the layer object.
        outNALayer = outNALayer.getOutput(0)
        
        #Get the names of all the sublayers within the route layer.
        subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
        #Stores the layer names that we will use later
        stopsLayerName = subLayerNames["Stops"]
        
        #Geocode the stop locations from a csv file containing the addresses.
        #The Geocode Addresses tool can use a text or csv file as input table
        #as long as the first line in the file contains the field names.
        arcpy.geocoding.GeocodeAddresses(inAddressTable, inAddressLocator, 
                                         inAddressFields, outStops)
        
        #Load the geocoded address locations as stops mapping the address field from
        #geocoded stop features as Name property using field mappings.
        fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, stopsLayerName)
        fieldMappings["Name"].mappedFieldName = "Address"
        arcpy.na.AddLocations(outNALayer, stopsLayerName, outStops, fieldMappings,
                              "", exclude_restricted_elements = "EXCLUDE")
        
        #Solve the route layer, ignore any invalid locations such as those that
        #can not be geocoded
        arcpy.na.Solve(outNALayer,"SKIP")
        
        #Save the solved route 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)
    
    MakeRouteLayer 示例 4(工作流)

    本例在单次求解中创建多条路径,常用于计算起始点-目的地对间的距离或行驶时间。

    # Name: MakeRouteLayer_MultiRouteWorkflow.py
    # Description: Calculate the home-work commutes for a set of people and save
    #              the output to a feature class
    # Requirements: Network Analyst Extension
    
    import datetime
    
    #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/SanFrancisco.gdb"
        env.overwriteOutput = True
    
        #Set local variables
        inNetworkDataset = "Transportation/Streets_ND"
        inStops_Home = "Analysis/Commuters_Home"
        inStops_Work = "Analysis/Commuters_Work"
        outNALayerName = "Commuters"
        outRoutesFC = "Analysis/outRoutes"
        impedanceAttribute = "TravelTime"
    
        #Set the time of day for the analysis to 8AM on a generic Monday.
        start_time = datetime.datetime(1900, 1, 1, 8, 0, 0)
    
        #Create a new Route layer.  Optimize on TravelTime, but compute the
        #distance traveled by accumulating the Meters attribute.
        outRouteResultObject = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName,
                                             impedanceAttribute,
                                             accumulate_attribute_name=["Meters"],
                                             hierarchy="NO_HIERARCHY",
                                             start_date_time=start_time)
    
        #Get the layer object from the result object. The route layer can now be
        #referenced using the layer object.
        outNALayer = outRouteResultObject.getOutput(0)
    
        #Get the names of all the sublayers within the route layer.
        subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
        #Store the layer names that we will use later
        stopsLayerName = subLayerNames["Stops"]
        routesLayerName = subLayerNames["Routes"]
    
        #Before loading the commuters' home and work locations as route stops, set
        #up field mapping.  Map the "Commuter_Name" field from the input data to
        #the RouteName property in the Stops sublayer, which ensures that each
        #unique Commuter_Name will be placed in a separate route.  Matching
        #Commuter_Names from inStops_Home and inStops_Work will end up in the same
        #route.
        fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, stopsLayerName)
        fieldMappings["RouteName"].mappedFieldName = "Commuter_Name"
    
        #Add the commuters' home and work locations as Stops. The same field mapping
        #works for both input feature classes because they both have a field called
        #"Commuter_Name"
        arcpy.na.AddLocations(outNALayer, stopsLayerName, inStops_Home,
                            fieldMappings, "",
                            exclude_restricted_elements = "EXCLUDE")
        arcpy.na.AddLocations(outNALayer, stopsLayerName, inStops_Work,
                            fieldMappings, "",
                            exclude_restricted_elements = "EXCLUDE")
    
        #Solve the route layer.
        arcpy.na.Solve(outNALayer)
    
        # Get the output Routes sublayer and save it to a feature class
        RoutesSubLayer = arcpy.mapping.ListLayers(outNALayer, routesLayerName)[0]
        arcpy.management.CopyFeatures(RoutesSubLayer, outRoutesFC)
    
        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: 是
    • Standard: 是
    • Advanced: 是

    相关主题

    • 路径分析
    • 关于使用等级进行网络分析
    • 时间窗
    • 分析工具集概述
    • 什么是网络分析图层?

    ArcGIS Desktop

    • 主页
    • ArcGIS Pro
    • ArcMap
    • 文档
    • 支持

    ArcGIS

    • ArcGIS Online
    • ArcGIS Desktop
    • ArcGIS Enterprise
    • ArcGIS Platform
    • ArcGIS Developer
    • ArcGIS Solutions
    • ArcGIS Marketplace

    关于 Esri

    • 关于我们
    • 招贤纳士
    • Esri 博客
    • 用户大会
    • 开发者峰会
    Esri
    Copyright © 2019 Esri. | 隐私政策 | 法律声明