ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.Topology Namespace / Topology Class
Members Example

In This Topic
    Topology Class
    In This Topic
    Represents a topology dataset.
    Object Model
    Topology ClassDatastore ClassTopologyDefinition ClassEnvelope ClassValidationResult Class
    Syntax
    public sealed class Topology : ArcGIS.Core.Data.Dataset, System.IDisposable  
    Public NotInheritable Class Topology 
       Inherits ArcGIS.Core.Data.Dataset
       Implements System.IDisposable 
    Example
    OpenTopologyAndProcessDefinition
    public void OpenTopologyAndProcessDefinition()
    {
      // Open a geodatabase topology from a file geodatabase and process the topology definition.
    
      using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\TestData\GrandTeton.gdb"))))
      using (Topology topology = geodatabase.OpenDataset<Topology>("Backcountry_Topology"))
      {
        ProcessDefinition(geodatabase, topology);
      }
    
      // Open a feature service topology and process the topology definition.
    
      const string TOPOLOGY_LAYER_ID = "0";
    
      using (Geodatabase geodatabase = new Geodatabase(new ServiceConnectionProperties(new Uri("https://sdkexamples.esri.com/server/rest/services/GrandTeton/FeatureServer"))))
      using (Topology topology = geodatabase.OpenDataset<Topology>(TOPOLOGY_LAYER_ID))
      {
        ProcessDefinition(geodatabase, topology);
      }
    }
    
    private void ProcessDefinition(Geodatabase geodatabase, Topology topology)
    {
      // Similar to the rest of the Definition objects in the Core.Data API, there are two ways to open a dataset's 
      // definition -- via the Topology dataset itself or via the Geodatabase.
    
      using (TopologyDefinition definitionViaTopology = topology.GetDefinition())
      {
        OutputDefinition(geodatabase, definitionViaTopology);
      }
    
      using (TopologyDefinition definitionViaGeodatabase = 
        geodatabase.GetDefinition<TopologyDefinition>("Backcountry_Topology"))
      {
        OutputDefinition(geodatabase, definitionViaGeodatabase);
      }
    }
    
    private void OutputDefinition(Geodatabase geodatabase, TopologyDefinition topologyDefinition)
    {
      Console.WriteLine($"Topology cluster tolerance => {topologyDefinition.GetClusterTolerance()}");
      Console.WriteLine($"Topology Z cluster tolerance => {topologyDefinition.GetZClusterTolerance()}");
    
      IReadOnlyList<string> featureClassNames = topologyDefinition.GetFeatureClassNames();
      Console.WriteLine($"There are {featureClassNames.Count} feature classes that are participating in the topology:");
    
      foreach (string name in featureClassNames)
      {
        // Open each feature class that participates in the topology.
    
        using (FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>(name))
        using (FeatureClassDefinition featureClassDefinition = featureClass.GetDefinition())
        {
          Console.WriteLine($"\t{featureClass.GetName()} ({featureClassDefinition.GetShapeType()})");
        }
      }
    }
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Dataset
             ArcGIS.Core.Data.Topology.Topology

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also