OpenDataset<T> Method (Geodatabase)
Gets a specific
Dataset instance associated with of type in the geodatabase. This method must be called on the MCT. Use QueuedTask.Run.
Public Function OpenDataset(Of As Dataset)( _
ByVal As String _
) As
Parameters
- name
-
The name of the dataset to open.
Type Parameters
- T
-
The type of dataset to open.
Return Value
A specific
Dataset instance corresponding to type .
Open a Terrain
public async Task OpenTerrain()
{
try
{
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
string path = @"d:\Data\Terrain\filegdb_Containing_A_Terrain.gdb";
var fileConnection = new FileGeodatabaseConnectionPath(new Uri(path));
using (Geodatabase dataStore = new Geodatabase(fileConnection))
{
string dsName = "nameOfTerrain";
using (var dataset = dataStore.OpenDataset<ArcGIS.Core.Data.Analyst3D.Terrain>(dsName))
{
}
}
});
}
catch (GeodatabaseNotFoundOrOpenedException exception)
{
// Handle Exception.
}
}
Opening datasets from Geodatabase
public async Task OpeningDatasetsFromGeodatabase()
{
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
{
using (Table table = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.EmployeeInfo"))
{
}
// Open a featureClass (within a feature dataset or outside a feature dataset).
using (FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>("LocalGovernment.GDB.AddressPoint"))
{
}
// You can open a FeatureClass as a Table which will give you a Table Reference.
using (Table featureClassAsTable = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.AddressPoint"))
{
// But it is really a FeatureClass object.
FeatureClass featureClassOpenedAsTable = featureClassAsTable as FeatureClass;
}
// Open a FeatureDataset.
using (FeatureDataset featureDataset = geodatabase.OpenDataset<FeatureDataset>("LocalGovernment.GDB.Address"))
{
}
// Open a RelationsipClass. Just as you can open a FeatureClass as a Table, you can also open an AttributedRelationshipClass as a RelationshipClass.
using (RelationshipClass relationshipClass = geodatabase.OpenDataset<RelationshipClass>("LocalGovernment.GDB.AddressPointHasSiteAddresses"))
{
}
}
});
}
Check if table is versioned
public bool IsTableVersioned(Geodatabase geodatabase, string tableName)
{
using (Table table = geodatabase.OpenDataset<Table>(tableName))
{
// Check table version type
RegistrationType registrationType = table.GetRegistrationType();
if (registrationType == RegistrationType.Versioned)
{
return true;
}
}
return false;
}
Open raster dataset in a geodatabase
// Create a FileGeodatabaseConnectionPath using the path to the gdb. Note: This can be a path to a .sde file.
FileGeodatabaseConnectionPath geodatabaseConnectionPath = new FileGeodatabaseConnectionPath(new Uri(@"C:\Temp\rasters.gdb"));
// Create a new Geodatabase object using the FileGeodatabaseConnectionPath.
Geodatabase geodatabase = new Geodatabase(geodatabaseConnectionPath);
// Open the raster dataset.
RasterDataset gdbRasterDataset = geodatabase.OpenDataset<RasterDataset>("sample");
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.