GetNAClassNames (arcpy.na)

摘要

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

讨论

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

网络分析类具有各种特性,具体取决于网络分析图层。一些类用于存储分析期间使用的输入,一些类用于存储从求解分析图层过程中获得的输出。如果类用作网络位置并具有不同的形状类型(例如点、线或面或者无形状(换句话说,表)),则类还可以有位置字段或位置范围。naclass_edit_typenalocation_typeshape_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:

  • ANYInclude all the classes from the network analysis layer. This is the default value.
  • INPUTInclude 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.
  • OUTPUTInclude 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:

  • ANYInclude the classes from the network analysis layer irrespective of whether they do or do not support location fields. This is the default value.
  • LOCATIONInclude only those classes from the network analysis layer that support location fields or location ranges.
  • NOT_LOCATIONInclude 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:

  • ANYInclude all shape type classes from the network analysis layer. This is the default value.
  • POINTInclude only point classes from the network analysis layer.
  • LINEInclude only line classes from the network analysis layer.
  • POLYGONInclude only polygon classes from the network analysis layer.
  • NULLInclude 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")

相关主题

9/15/2013