ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

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

描述

  • 描述
  • 使用
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

根据包含路径的网络分析图层生成转弯方向。可以将这些方向信息写入到文本、XML 或 HTML 格式的文件中。如果提供了适合的样式表,也可以将这些方向写入其他任何文件格式。

使用

  • 使用工具时如果未得到有效结果,那么该工具会自动求解网络分析图层,因此在生成方向之前,您不需要先求解网络分析图层。

语法

Directions(in_network_analysis_layer, file_type, out_directions_file, report_units, {report_time}, {time_attribute}, {language}, {style_name}, {stylesheet})
参数说明数据类型
in_network_analysis_layer

将生成方向信息的网络分析图层。只能为路径、最近设施点和车辆配送网络分析图层生成方向信息。

Network Analyst Layer
file_type

输出方向文件的格式。如果样式表参数中具有值,则会忽略此参数。

  • XML —将以 XML 文件的形式生成输出方向文件。除了路径的方向字符串和长度及时间信息外,该文件还包含有关每个方向的行进策略类型和转弯角度的信息。
  • TEXT —将以简单 TXT 文件的形式生成输出方向文件,其中包含路径的方向字符串和长度信息,另外还可包含路径的时间信息。
  • HTML —将以 HTML 文件的形式生成输出方向文件,其中包含路径的方向字符串和长度信息,另外还可包含路径的时间信息。
String
out_directions_file

如果在 stylesheet 参数中提供样式表,应确保 out_directions_file 的文件后缀与样式表生成的文件类型匹配。

File
report_units

指定在方向文件中报告长度信息时所使用的线性单位。例如,即使阻抗的单位是米,您也可以选择使用英里显示方向。

  • Feet —英尺
  • Yards —码
  • Miles —英里
  • Meters —米
  • Kilometers —千米
  • NauticalMiles —海里
String
report_time
(可选)
  • NO_REPORT_TIME —在方向文件中不报告行驶时间。
  • REPORT_TIME —在方向文件中报告行驶时间。这是默认设置。
Boolean
time_attribute
(可选)

用于提供方向中各行驶时间的基于时间的成本属性。输入网络分析图层所使用的网络数据集中必须存在成本属性。

String
language
(可选)

选择生成驾车方向时所使用的语言。下拉列表中显示的语言类别取决于您的计算机中所包含的 ArcGIS 语言包。

请注意,如果要将此工具作为独立服务器服务的一部分进行发布,那么必须确保与您所选语言相对应的 ArcGIS 语言包已经安装到服务器上,这样才能够保证工具正常工作。而且,如果某一语言包未被安装到您的计算机中,该语言将不会显示在下拉列表中;不过,您可以直接键入语言代码而无需从中进行选择。

String
style_name
(可选)

选择方向的格式化样式名称。

  • NA Desktop —可打印转弯方向
  • NA Navigation —针对车辆内导航设备设计的转弯方向
  • NA Campus —转弯行走方向,用于人行道
String
stylesheet
(可选)

生成格式化输出文件类型(如 PDF、Word 或 HTML 文件)的样式表。输出方向文件参数中的文件后缀应与样式表所生成的文件类型相匹配。如果此参数中包含了参数值,则方向工具会重写输出文件类型参数。

提示:

如果想要领先创建自有文本和 HTML 样式表,应复制和编辑 Network Analyst 使用的样式表。它们位于以下目录中:<ArcGIS installation directory>\ArcGIS\Desktop10.2.1\NetworkAnalyst\Directions\Styles。样式表为 Dir2PHTML.xsl,文本样式表为 Dir2PlainText.xsl。

File

派生输出

名称说明数据类型
output_layer

具有路径的更新网络分析图层。

网络分析图层

代码示例

Directions 示例 1(Python 窗口)

使用所有参数执行“方向”工具。

arcpy.na.Directions("Route", "TEXT", "C:/Data/Route_Directions.txt", "Miles",
                    "REPORT_TIME", "Minutes")
Directions 示例 2(工作流)

以下独立 Python 脚本演示了如何使用 Directions 工具中为某条路径生成一个 HTML 文件格式的驾车方向。

# Name: Directions_Workflow.py
# Description: Generate driving directions in a html file for a route that 
#              visits the store locations in the best sequence that minimizes 
#              the total travel time
# 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 = "StoreRoute"
    impedanceAttribute = "TravelTime"
    startLocation = "Analysis/DistributionCenter"
    storeLocations = "Analysis/Stores"
    #fieldMappings = "Name Name #; Attr_TravelTime ServiceTime #"
    outDirectionsFile = "C:/data/output" + "/" + outNALayerName + "Directions.html"
    outLayerFile = "C:/data/output" + "/" + outNALayerName + ".lyr"
    
    #Create a new route layer. The route starts at the distribution center and 
    #takes the best sequence to visit the store locations.
    outNALayer = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName,
                                         impedanceAttribute, "FIND_BEST_ORDER",
                                         "PRESERVE_FIRST","",['Meters'],
                                         "NO_UTURNS",start_date_time="8 AM")
    
    #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"]
    
    #Load the distribution center as the start location using default field 
    #mappings and search tolerance
    arcpy.na.AddLocations(outNALayer,stopsLayerName,startLocation,"","",
                          exclude_restricted_elements = "EXCLUDE")
    
    #Load the store locations as stops. Make sure the store locations are 
    #appended to the Stops sublayer which already contains the distribution 
    #center location. Map the Attr_TravelTime property from the ServiceTime 
    #field so that the total travel time for the route will also contain the 
    #service time using the field mappings
    fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, stopsLayerName)
    fieldMappings["Name"].mappedFieldName = "Name"
    fieldMappings["Attr_" + impedanceAttribute].mappedFieldName = "ServiceTime"
    arcpy.na.AddLocations(outNALayer, stopsLayerName, storeLocations,
                          fieldMappings, "", append="APPEND",
                          exclude_restricted_elements = "EXCLUDE")
    
    #Generate driving directions in a HTML file
    arcpy.na.Directions(outNALayer,"HTML",outDirectionsFile,"Miles",
                        "REPORT_TIME",impedanceAttribute)
    
    #Save the solved na layer as a layer file on disk using relative paths
    arcpy.SaveToLayerFile_management(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

相关主题

  • 分析工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

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