This document is archived and information here might be outdated.  Recommended version.


NetworkDataset CoClass (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > Geodatabase > ESRI.ArcGIS.GeoDatabase > Classes > N > NetworkDataset CoClass (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (GeoDatabase)  

NetworkDataset CoClass

A container for querying information about a network dataset.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

A NetworkDataset is a collection of feature classes called network sources, that participate in a network relationship. Each feature class has a topological role in the network and a network may have multiple feature classes in the same role. A feature dataset may have multiple networks but a feature class can only belong to one network dataset.

Network datasets may also have any number of network attributes, which are used for network analysis such as finding the shortest path or performing a service area analysis.  The INetworkAttribute interface has the properties that return information on the network attribute, such as it data or usage type.

Schema changes to a network dataset may be performed through two different mechanisms  The INetworkBuild interface allows for the addition or removal of individual sources or attributes.  Multiple schema edits to a network dataset can be performed by using the INetworkBuild::UpdateSchema method and an IDENetworkDataset object.

Extended Error Information

Use the ISupportErrorInfo method InterfaceSupportsErrorInfo to determine if the object supports extended error information. If the object supports extended error info, VC++ developers should use the OLE/COM IErrorInfo interface to access the ErrorInfo object. Visual Basic developers should use the global error object Err to retrieve this extended error information.

Interfaces

Interfaces Description
IDataset Provides access to members that supply dataset information.
IDatasetAnalyze Provides access to members that analyze a dataset.
IDatasetComponent2 Provides access to the common functionality found on all dataset components.
IDatasetEdit Provides access to information about the status of datasets being edited.
IDatasetEditInfo Provides access to members that maintain dataset editing information.
IFeatureClassContainer Provides access to members that return feature classes by name, ID and index.
IGeoDataset Provides access to members that provide information about a Geographic Dataset.
IGeoDatasetSchemaEdit Provides access to members that change the schema of a GeoDataset.
IMetadata Provides access to members that manage and update metadata.
IMetadataEdit Provides access to members that provide information about whether metadata can be edited.
INativeTypeInfo Provides access to the native type.
INetworkBuild Provides access to members for changing the schema of a network dataset and building it.
INetworkDataset Provides access to members that query the schema of the network dataset.
INetworkDataset2 Provides access to members that query the schema of the network dataset.
INetworkQuery Provides access to members that query the elements of the network dataset.
INetworkQuery2 Provides access to members that query the elements of the network dataset.
INetworkQuery3 Provides access to members that query the elements of the network dataset.
ISchemaLock Provides access to members for accessing schema locking functionality.
ISupportErrorInfo (esriSystem)
IVersionedObject2 Provides access to members that manage a versioned object.

Remarks

In order to create a new network dataset or to an open an existing one, you must first get access to the NetworkDatasetFDExtension object (for network datasets in a geodatabase feature dataset) or the NetworkDatasetWorkspaceExtension object (for shapefile network datasets).  Once you have the appropriate extension object, you can QI to the IDatasetContainer2 interface to create or open a network dataset.

When working with a Map, you can open a network dataset from its NetworkLayer by calling INetworkLayer.NetworkDataset.

The IDatasetContainer2.CreateDataset method should be used for creating network datasets. Network Datasets must be built after creation, using the INetworkBuild.BuildNetwork method.

The NetworkDatasetName objects of the network datasets can be accessed by the IDatasetContainer2.DatasetNames method.

[C#]

The following code demonstrates how to get the network dataset extension object from the given geodatabase feature dataset (fds):

IFeatureDatasetExtensionContainer fdsExtCont=fds as IFeatureDatasetExtensionContainer;
IFeatureDatasetExtension fdsExt=fdsExtCont.FindExtension(esriDTNetworkDataset);
IDatasetContainer2 dsCont=fdsExt as IDatasetContainer2;

The following code demonstrates how to get the network dataset extension object from the given shapefile workspace (shpWS):

IWorkspaceExtensionManager wsExtMgr=shpWS as IWorkspaceExtensionManager;
UID myUID=new UIDClass();
myUID.Value="esriGeoDatabase.NetworkDatasetWorkspaceExtension";
IWorkspaceExtension wsExt=wsExtMgr.FindExtension(myUID);  
IDatasetContainer2 dsCont=wsExt as IDatasetContainer2;

The following code demonstrates how to get the network dataset extension object from the given SDC workspace (sdcWS):

IWorkspaceExtensionManager wsExtMgr=sdcWS as IWorkspaceExtensionManager;
UID myUID=new UIDClass();
myUID.Value="esriGeoDatabase.NetworkDatasetWorkspaceExtension";
IWorkspaceExtension wsExt=wsExtMgr.FindExtension(myUID);
IDatasetContainer2 dsCont=wsExt as IDatasetContainer2;

Once you have hold of the IDatasetContainer2 interface on the appropriate network dataset extension object, you can now access its network datasets. For example, adding the following lines of code will open a network dataset with the name Street_ND :

IDataset dataset=dsCont.DatasetByName(esriDTNetworkDataset, "Street_ND");
INetworkDataset networkDataset=dataset as INetworkDataset;
[Visual Basic .NET]

The following code demonstrates how to get the network dataset extension object from the given geodatabase feature dataset (fds):

Dim fdsExtCont As IFeatureDatasetExtensionContainer=CType(fds, IFeatureDatasetExtensionContainer)
Dim fdsExt As IFeatureDatasetExtension=fdsExtCont.FindExtension(esriDTNetworkDataset)
Dim dsCont As IDatasetContainer2=CType(fdsExt, IDatasetContainer2)

The following code demonstrates how to get the network dataset extension object from the given shapefile workspace (shpWS):

Dim wsExtMgr As IWorkspaceExtensionManager=CType(shpWS, IWorkspaceExtensionManager)
Dim myUID As New UID
myUID.Value="esriGeoDatabase.NetworkDatasetWorkspaceExtension"
Dim wsExt As IWorkspaceExtension=wsExtMgr.FindExtension(myUID)
Dim dsCont As IDatasetContainer2=CType(wsExt, IDatasetContainer2)

The following code demonstrates how to get the network dataset extension object from the given SDC workspace (sdcWS):

Dim wsExtMgr As IWorkspaceExtensionManager=CType(sdcWS, IWorkspaceExtensionManager)
Dim myUID As New UID
myUID.Value="esriGeoDatabase.NetworkDatasetWorkspaceExtension"
Dim wsExt As IWorkspaceExtension=wsExtMgr.FindExtension(myUID)
Dim dsCont As IDatasetContainer2=CType(wsExt, IDatasetContainer2)

Once you have hold of the IDatasetContainer2 interface on the appropriate network dataset extension object, you can now access its network datasets. For example, adding the following lines of code will open a network dataset with the name Street_ND:

Dim dataset As IDataset=dsCont.DatasetByName(esriDTNetworkDataset, "Street_ND")
Dim networkDataset As INetworkDataset=CType(dataset, INetworkDataset)