GetNAClassNames (arcpy.na)
サマリ
Returns a dictionary of network analysis class names from the network analysis layer specified as argument. The dictionary keys are the network analysis class names, and the values are the layer names that reference the network analysis classes from the network analysis layer. The layer names are used as input in some geoprocessing tools such as Add Locations and Add Field To Analysis Layer.
説明
A network analysis layer is made up of one or more network analysis classes. Each network analysis class is a feature layer or a table view that references a feature class or a table. This function returns a mapping between those feature class or table names and their corresponding feature layer or table view names. The layer names are not constants, as they can be edited by an end user or can be localized by a foreign language version of ArcGIS. This function helps to write portable script code that runs across different ArcGIS language versions. The dictionary keys always remain constant and can be used to obtain the variable layer name for a given network analysis class.
Network analysis classes have various characteristics depending on the network analysis layer. Some of the classes are used to store inputs that are used during analysis, while some are used to store the outputs obtained from solving the analysis layer. The classes can also have location fields or location ranges if they act as network locations and have different shape types such as points, lines, or polygons or no shapes (in other words, tables). The naclass_edit_type, nalocation_type, and shape_type arguments can be used to further filter the list of network analysis classes. For example, the Sub Layer parameter in the Add Locations tool lists only those network analysis classes that support input edit mode, so such a list can be obtained by using INPUT as the value for the naclass_edit_type argument.
構文
パラメータ | 説明 | データ タイプ |
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) | 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) | 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) | String |
データ タイプ | 説明 |
Dictionary |
A dictionary object whose keys are the network analysis class names and values are the layer names that reference the network analysis classes from the network analysis layer. |
コードのサンプル
This example shows how to generate one-, two-, and three-minute service area polygons around fire stations and export the service areas as a feature class in a geodatabase. It illustrates how the GetNAClassNames function can be used to derive values that can be used as input for other ArcPy functions.
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")