How to open a terrain dataset (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > ArcGIS extensions > 3D Analyst > Analysis in 3D > How to open a terrain dataset (ArcObjects .NET 10.6 SDK)

How to open a terrain dataset


Opening a terrain dataset

This topic shows how to get a reference to a terrain dataset from a feature workspace:
  1. Obtain a handle to the feature workspace containing the terrain dataset. See the following code example:
[C#]
// Get a feature workspace that contains a terrain.
IWorkspaceFactory WSFact=new FileGDBWorkspaceFactoryClass();
IFeatureWorkspace FWS;
FWS=WSFact.OpenFromFile("C:\\project\\terrain.gdb", 0)as IFeatureWorkspace;
[VB.NET]
' Get a feature workspace that contains a terrain.
Dim WSFact As IWorkspaceFactory=New FileGDBWorkspaceFactoryClass()
Dim FWS As IFeatureWorkspace
FWS=TryCast(WSFact.OpenFromFile("C:\project\terrain.gdb", 0), IFeatureWorkspace)
  1. Get the feature dataset inside the workspace that contains the terrain dataset. See the following code example:
[C#]
// From the workspace, get a feature dataset that contains a terrain.
IFeatureDataset FDS=FWS.OpenFeatureDataset("myFDS");
[VB.NET]
' From the workspace, get a feature dataset that contains a terrain.
Dim FDS As IFeatureDataset=FWS.OpenFeatureDataset("myFDS")
  1. From the feature dataset, open the terrain. See the following code example:
[C#]
// Open the terrain.
IFeatureDatasetExtensionContainer EC=FDS as IFeatureDatasetExtensionContainer;
IDatasetContainer3 DC=EC.FindExtension(esriDatasetType.esriDTTerrain)as
    IDatasetContainer3;
ITerrain Terrain=DC.get_DatasetByName(esriDatasetType.esriDTTerrain, "myTerrain")
    as ITerrain;
[VB.NET]
' Open the terrain.
Dim EC As IFeatureDatasetExtensionContainer=TryCast(FDS, IFeatureDatasetExtensionContainer)
Dim DC As IDatasetContainer3=TryCast(EC.FindExtension(esriDatasetType.esriDTTerrain), IDatasetContainer3)
Dim Terrain As ITerrain=TryCast(DC.get_DatasetByName(esriDatasetType.esriDTTerrain, "myTerrain"), ITerrain)






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine