In this topic
Accessing a file-based raster dataset
To access a file-based raster dataset, use IRasterWorkspace and perform the following steps:
- Open a raster file workspace.
- Open a file raster dataset.
See the following code example:
[C#] static IRasterDataset OpenFileRasterDataset(string folderName, string datasetName)
{
//Open a raster file workspace.
IWorkspaceFactory workspaceFactory=new RasterWorkspaceFactoryClass();
IRasterWorkspace rasterWorkspace=(IRasterWorkspace)
workspaceFactory.OpenFromFile(folderName, 0);
//Open a file raster dataset.
IRasterDataset rasterDataset=rasterWorkspace.OpenRasterDataset(datasetName);
return rasterDataset;
}
[VB.NET] Public Function OpenFileRasterDataset(ByVal folderName As String, ByVal datasetName As String) As IRasterDataset
'Open a raster file workspace.
Dim workspaceFactory As IWorkspaceFactory=New RasterWorkspaceFactoryClass()
Dim rasterWorkspace As IRasterWorkspace=CType(workspaceFactory.OpenFromFile(folderName, 0), IRasterWorkspace)
'Open a file raster dataset.
Dim rasterDataset As IRasterDataset=rasterWorkspace.OpenRasterDataset(datasetName)
Return rasterDataset
End Function
Accessing a geodatabase raster dataset
To access a raster dataset in a geodatabase, first open a geodatabase workspace (see Accessing raster workspaces for details). Then use the IRasterWorkspaceEx interface as shown in the following code example:
[C#] static IRasterDataset OpenGDBRasterDataset(IRasterWorkspaceEx rasterWorkspaceEx,
string datasetName)
{
//Open a raster dataset in a geodatabase (PGDB, FGDB, or ArcSDE).
return rasterWorkspaceEx.OpenRasterDataset(datasetName);
}
[VB.NET] Public Function OpenGDBRasterDataset(ByVal rasterWorkspaceEx As IRasterWorkspaceEx, ByVal datasetName As String) As IRasterDataset
'Open a raster dataset in a geodatabase (PGDB, FGDB, or ArcSDE).
Return rasterWorkspaceEx.OpenRasterDataset(datasetName)
End Function
See Also:
How to access a raster catalogAccessing a raster dataset in a raster catalog
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):
- ESRI.ArcGIS.DataSourcesGDB
- ESRI.ArcGIS.DataSourcesRaster
- ESRI.ArcGIS.Geodatabase
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
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 |