ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

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

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

GetNAClassNames

  • 摘要
  • 讨论
  • 语法
  • 代码实例

摘要

返回指定为参数的网络分析图层中的网络分析类名称字典。字典关键字是网络分析类名称,值是从网络分析图层中引用的网络分析类的图层名称。图层名称在某些地理处理工具(例如添加位置和向分析图层添加字段)中作为输入信息使用。

讨论

网络分析图层由一个或多个网络分析类组成。每个网络分析类都是一个引用了要素类或表的要素图层或表视图。此函数返回这些要素类或表名称与对应的要素图层或表视图名称之间的映射。图层名称不是常量,因为最终用户可以对其进行编辑,也可以将其本地化为 ArcGIS 的其他语言版本。此函数有助于编写跨不同 ArcGIS 语言版本运行的便携脚本代码。字典关键字始终保持不变,可用于获取指定网络分析类的可变图层名称。

网络分析类具有各种特性,具体取决于网络分析图层。一些类用于存储分析期间使用的输入,一些类用于存储从求解分析图层过程中获得的输出。如果类用作网络位置并具有不同的形状类型(例如点、线或面或者无形状(换句话说,表)),则类还可以有位置字段或位置范围。naclass_edit_type、nalocation_type 和 shape_type 参数可用于进一步过滤网络分析类的列表。例如,添加位置工具中的“子图层”参数仅列出支持输入编辑模式的网络分析类,因此可使用 INPUT 作为 naclass_edit_type 参数的值来获得这样的列表。

语法

GetNAClassNames (network_analyst_layer, {naclass_edit_type}, {nalocation_type}, {shape_type})
参数说明数据类型
network_analyst_layer

A variable that references a Layer object obtained from a network analysis layer. It can be derived from existing layers in a map document or by specifying the catalog path to the network analysis layer file as an argument to the Layer class. The isNetworkAnalystLayer property on the Layer object can be used to identify whether a given Layer object is a network analysis layer.

Layer
naclass_edit_type

A string that specifies which network analysis classes are included in the output dictionary based on their edit mode in the network analysis layer. The argument value can be one of the following string keywords:

  • ANY —Include all the classes from the network analysis layer. This is the default value.
  • INPUT —Include only those classes that support an input mode in the network analysis layer. This option will also include classes that support both input and output modes.
  • OUTPUT —Include only those classes that support an output mode in the network analysis layer. This option will also include classes that support both input and output modes.

(默认值为 ANY)

String
nalocation_type

A string that specifies which network analysis classes are included in the output dictionary based on their support for location fields. The argument value can be one of the following string keywords:

  • ANY —Include the classes from the network analysis layer irrespective of whether they do or do not support location fields. This is the default value.
  • LOCATION —Include only those classes from the network analysis layer that support location fields or location ranges.
  • NOT_LOCATION —Include only those classes from the network analysis layer that do not support location fields or location ranges.

(默认值为 ANY)

String
shape_type

A string that specifies which network analysis classes are included in the output dictionary based on their shape type. The argument value can be one of the following string keywords:

  • ANY —Include all shape type classes from the network analysis layer. This is the default value.
  • POINT —Include only point classes from the network analysis layer.
  • LINE —Include only line classes from the network analysis layer.
  • POLYGON —Include only polygon classes from the network analysis layer.
  • NULL —Include only tables from the network analysis layer.

(默认值为 ANY)

String

返回值

数据类型说明
Dictionary

一个字典对象,其关键字是网络分析类名称,值是从网络分析图层中引用的网络分析类的图层名称。

代码实例

GetNAClassNames 示例(工作流)

该示例展示了如何在消防站周围生成 1 分钟、2 分钟和 3 分钟服务区域面,并将这些服务区域导出为地理数据库中的要素类。它说明了如何使用 GetNAClassNames 函数来获取可用作其他 ArcPy 函数输入的值。

import arcpy

#Set up the environment
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("network")

#Set up variables
networkDataset = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
facilities = "C:/Data/SanFrancisco.gdb/Analysis/FireStations"
outputPolygons = "C:/Data/SanFrancisco.gdb/FireStationServiceAreas"

#Make a new service area layer
serviceAreaLayer = arcpy.na.MakeServiceAreaLayer(networkDataset, "FireStationServiceAreas",
                                                 "TravelTime", "TRAVEL_FROM",
                                                 "1 2 3").getOutput(0)

#Get the network analysis class names from the service area layer
naClasses = arcpy.na.GetNAClassNames(serviceAreaLayer)

#Load fire stations as facilities
arcpy.na.AddLocations(serviceAreaLayer, naClasses["Facilities"], facilities)

#Solve the service area layer
arcpy.na.Solve(serviceAreaLayer)

#Get the polygons sublayer from the service area layer
polygonsSublayer = arcpy.mapping.ListLayers(serviceAreaLayer,
                                            naClasses["SAPolygons"])[0]

#Export the polygons sublayer as a feature class
arcpy.management.CopyFeatures(polygonsSublayer, outputPolygons)

arcpy.AddMessage("Completed")

相关主题

  • 什么是网络分析类?
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

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

关于 Esri

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