Zusammenfassung
Provides read-only access to the properties of a network dataset. You can use this class to retrieve the properties and attribute values for network dataset edges, junctions, and turns, as well as other properties of the network dataset itself.
Syntax
NetworkDataset (in_network)
Parameter | Erklärung | Datentyp |
in_network | The network dataset whose properties you want to retrieve. The argument can be specified using the catalog path to the network dataset, a network dataset layer object, or the string name of the network dataset layer. | String |
Eigenschaften
Eigenschaft | Erklärung | Datentyp |
buildTimestamp (Nur lesen) | The date and time the network dataset was most recently built. | DateTime |
isBuilt (Nur lesen) | Indicates whether the network dataset is built. A value of False indicates that the network dataset needs to be rebuilt to incorporate changes. | Boolean |
travelModes (Nur lesen) | Returns a dictionary of travel mode objects that are available on the network dataset. The dictionary keys are the names of the travel modes, and the dictionary values are the travel mode objects. This property returns the same output as the GetTravelModes function. | Dictionary |
Methodenübersicht
Methode | Erklärung |
checkIntersectingFeatures (feature_layer, cutoff) | Returns a Boolean value indicating whether the number of edge source features from the specified network dataset that are intersected by the features within the specified feature layer is less than or equal to the specified cutoff. This is useful for restricting the number of features that can be loaded as line or polygon barriers into a network analysis problem. This method is similar to the CheckIntersectingFeatures function. |
describe () | Returns a Describe object that contains additional properties of the network dataset. This is equivalent to using arcpy.Describe on the network dataset. |
edges ({edge_properties}, {attribute_names}, {time_of_day}, {eids}) | Returns an iterator of network dataset edge elements you can use to access the value of specific edge properties and network attributes at the time of day specified. |
getDataSourceFromSourceID (source_id) | Returns the catalog path of the network dataset source feature class identified by the given source ID. |
junctions ({junction_properties}, {attribute_names}, {time_of_day}, {eids}) | Returns an iterator of network dataset junction elements that you can use to access the value of specific junction properties and network attributes at the time of day specified. |
turns ({turn_properties}, {attribute_names}, {eids}) | Returns an iterator of network dataset turn elements you can use to access the value of specific turn properties and network attributes. |
Methoden
checkIntersectingFeatures (feature_layer, cutoff)
Parameter | Erklärung | Datentyp |
feature_layer | A Layer object containing the features that intersect the network edge sources. Any selection set or definition query present on the layer object is honored and can be used to specify only a subset of features. | Layer |
cutoff | The maximum number of intersecting features. | Integer |
Datentyp | Erklärung |
Boolean | Returns True if the number of intersecting features is less than or equal to the cutoff value. Returns False if the number of intersecting features exceeds the cutoff value. |
edges ({edge_properties}, {attribute_names}, {time_of_day}, {eids})
Parameter | Erklärung | Datentyp |
edge_properties [edge_properties,...] | A list of strings representing the network edge properties to retrieve. For a single property, you can use a string instead of a list of strings. The available properties include the following:
| String |
attribute_names [attribute_names,...] | The list of network dataset attribute names, such as costs or restrictions, for which to retrieve the value for each network element. If the value is time dependent, you can specify the time of day using the time_of_day parameter. For a single attribute, you can use a string instead of a list of strings. | String |
time_of_day | The time of day for which to retrieve time-dependent attribute values for this network element. When no time of day value is passed, the time-neutral value will be returned. | DateTime |
eids [eids,...] | A list of EID values to include in the cursor. This allows you to return only a subset of all network elements. If no value is passed for this parameter, all network elements are returned. | Integer |
Datentyp | Erklärung |
Object | A NetworkDatasetEdgeCursor object that can be used to iterate over the returned edges. Each row is a tuple with the values of the items specified in the edge_properties and attribute_names parameters for that edge. |
getDataSourceFromSourceID (source_id)
Parameter | Erklärung | Datentyp |
source_id | The network source ID for which the corresponding source feature class's catalog path will be retrieved. | Integer |
Datentyp | Erklärung |
String | The catalog path of the network dataset source feature class. |
junctions ({junction_properties}, {attribute_names}, {time_of_day}, {eids})
Parameter | Erklärung | Datentyp |
junction_properties [junction_properties,...] | A list of strings representing the network junction properties to retrieve. For a single property, you can use a string instead of a list of strings. The available properties include the following:
| String |
attribute_names [attribute_names,...] | The list of network dataset attribute names, such as costs or restrictions, for which the value of each network element will be retrieved. If the value is time dependent, you can specify the time of day using the time_of_day parameter. For a single attribute, you can use a string instead of a list of strings. | String |
time_of_day | The time of day that time-dependent attribute values for this network element will be retrieved. When no time of day value is passed, the time-neutral value will be returned. | DateTime |
eids [eids,...] | A list of EID values to include in the cursor. This allows you to return only a subset of all network elements. If no value is passed for this parameter, all network elements are returned. | Integer |
Datentyp | Erklärung |
Object | A NetworkDatasetJunctionCursor object that can be used to iterate over the returned junctions. Each row is a tuple with the values of the items specified in the junction_properties and attribute_names parameters for that junction. |
turns ({turn_properties}, {attribute_names}, {eids})
Parameter | Erklärung | Datentyp |
turn_properties [turn_properties,...] | A list of strings representing the network turn properties to retrieve. For a single property, you can use a string instead of a list of strings. The available properties include the following:
| String |
attribute_names [attribute_names,...] | The list of network dataset attribute names, such as costs or restrictions, for which to retrieve the value for each network element. For a single attribute, you can use a string instead of a list of strings. | String |
eids [eids,...] | A list of EID values to include in the cursor. This allows you to return only a subset of all network elements. If no value is passed for this parameter, all network elements are returned. | Integer |
Datentyp | Erklärung |
Object | A NetworkDatasetTurnCursor object that can be used to iterate over the returned turns. Each row is a tuple with the values of the items specified in the turn_properties and attribute_names parameters for that turn. |
Codebeispiel
Print the travel time for each edge in the network that is not restricted to automobiles.
# Print the travel time for each edge in the network that is not restricted to automobiles
import datetime
import arcpy
arcpy.CheckOutExtension("network")
nds_path = r"E:\TutorialData\Network Analyst\Tutorial\SanDiego.gdb\Transportation\Streets_ND"
# Initialize the NetworkDataset object
nds = arcpy.nax.NetworkDataset(nds_path)
# Print network dataset build information
print(f"Network dataset is built: {nds.isBuilt}")
print(f"Most recent build time: {nds.buildTimestamp}")
# Iterate through all the edges in the network and get the TravelTime cost attribute
# value for a specific time of day. Only print the value if the edge is not restricted
# to automobiles
edges = nds.edges("EID", ["TravelTime", "Driving an Automobile"], datetime.datetime(2019, 4, 19, 8, 0, 0))
for edge in edges:
if not edge[2]:
print(f"TravelTime for EID {edge[0]}: {edge[1]}")
Retrieve the ObjectID values of all junctions for all edges that participate in turns.
# Retrieve the ObjectIDs of all junctions for all edges that participate in turns
import arcpy
arcpy.CheckOutExtension("network")
nds_path = r"E:\TutorialData\Network Analyst\Tutorial\SanDiego.gdb\Transportation\Streets_ND"
# Initialize the NetworkDataset object
nds = arcpy.nax.NetworkDataset(nds_path)
# Iterate through all turns in the network and get the edges that participate
turns = nds.turns(["SOURCEOID", "EDGEEIDS"])
for turn in turns:
# For the edges in the turn, get the from and to junctions
edges = nds.edges(["SOURCEOID", "FROMJUNCTION", "TOJUNCTION"], eids=turn[1])
for edge in edges:
# For the from and to junction, get the SOURCEOID
junctions = nds.junctions("SOURCEOID", eids=[edge[1], edge[2]])
junctionOIDs = [j[0] for j in junctions]