Provides the ability to map field names or set default values for the properties of a network analysis class within a network analysis layer. The properties of the network analysis class are used as inputs by the solvers while performing the network analyses.
The NAClassFieldMap object cannot be instantiated by itself. It is obtained by instantiating an NAClassFieldMappings object, which returns a collection of NAClassFieldMap objects as a Python dictionary. The dictionary keys are the network analysis class property names, and the values are the NAClassFieldMap objects.
(Read and Write)
Provides the ability to get or set the default value for the property represented by the NAClassFieldMap object. The value can be specified as a string representation of the value or as a value of the data type for the property. For example, the Curb Approach property can have default value specified as number 1 or as a string "1". The default value cannot be set for the Locations property in the Line Barriers and Polygon Barriers sublayer as they require BLOB values. If both mappedFieldName and defaultValue properties are specified for a property, the default value is used only if the feature attribute value corresponding to the mapped field has a null value.
(Read and Write)
Provides the ability to get or set the field name from an input feature class or table that is used to derive the value for the property. If the feature attribute value corresponding to the mapped field has a null value, the value specified for the defaultValue property is used.
The name of the property for which a default value or a mapped field name is specified using the NAClassFieldMap object.
The following script shows how to load fire stations as facilities into an existing service area layer and specify a delay of 10 minutes when loading the facilities using the NAClassFieldMappings object. It assumes that a service area network analysis layer called Fire Stations Coverage, created from the tutorial network dataset for the San Francisco region, and a feature layer called FireStations are already added to an existing map document.
#Get the service area layer called "Fire Stations Coverage" from the map doc = arcpy.mp.ArcGISProject('current') map_obj = doc.listMaps() sa_layer = map_obj.listLayers("Fire Stations Coverage") #Get the list of fields from the FireStations feature layer in the map fields = arcpy.ListFields("FireStations") #Get the facilities sublayer name from the service area layer. Note that we are #not using a string called "Facilities" because the sublayer name can be #different if using ArcGIS on a non-English operating system. facilities_sublayer_name = arcpy.na.GetNAClassNames(sa_layer)["Facilities"] #Create a field mappings object for facilities sublayer based on the fields from #FireStations layer field_mappings = arcpy.na.NAClassFieldMappings(sa_layer, facilities_sublayer_name, False, fields) #Get the field map corresponding to the "Attr_TravelTime" property of facilities field_map = field_mappings["Attr_TravelTime"] #Set a delay of 10 minutes for the facilities field_map.defaultValue = 10 #Load the fire stations as service area facilities using the field mappings arcpy.na.AddLocations(sa_layer, facilities_sublayer_name, "FireStations", field_mappings)