Accessing raster workspaces (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Accessing raster datasets > Accessing raster workspaces (ArcObjects .NET 10.6 SDK)

Accessing raster workspaces


Summary
Rasters can reside in a folder, a personal geodatabase, a file geodatabase, or an ArcSDE geodatabase. This topic shows how to access different types of workspaces as raster workspaces.

About accessing raster workspaces

All geodatabase workspaces support the IRasterWorkspaceEx interface, while file workspaces support IRasterWorkspace. To access raster workspaces, see the following code example:
[C#]
//Open a file geodatabase workspace as RasterWorkspace.
static IRasterWorkspaceEx OpenFGDB(string FGDBPath)
{
    //FGDBPath string example: c:\data\raster.gdb.
    IWorkspaceFactory2 workspaceFactory=new FileGDBWorkspaceFactoryClass();
    return (IRasterWorkspaceEx)workspaceFactory.OpenFromFile(FGDBPath, 0);
}

//Open an ArcSDE workspace as RasterWorkspace.
static IRasterWorkspaceEx OpenSDE(string conString)
{
    //conString example: SERVER=ais;INSTANCE=9200;VERSION=sde.DEFAULT;USER=raster;PASSWORD=raster.
    IWorkspaceFactory2 workspaceFactory=new SdeWorkspaceFactoryClass();
    return (IRasterWorkspaceEx)workspaceFactory.OpenFromString(conString, 0);
}

//Open an accessed workspace as RasterWorkspace.
static IRasterWorkspaceEx OpenAccess(string PGDBPath)
{
    //FGDBPath string example: c:\data\rasters.mdb.
    IWorkspaceFactory2 workspaceFactory=new AccessWorkspaceFactoryClass();
    return (IRasterWorkspaceEx)workspaceFactory.OpenFromFile(PGDBPath, 0);
}

//Open a file workspace as RasterWorkspace.
static IRasterWorkspace OpenFileWorkspace(string wsPath)
{
    //wsPath example: c:\data\rasters.
    IWorkspaceFactory workspaceFact=new RasterWorkspaceFactoryClass();
    return (IRasterWorkspace)workspaceFact.OpenFromFile(wsPath, 0);
}
[VB.NET]
'Open a file geodatabase workspace as RasterWorkspace.

Public Function OpenFGDB(ByVal FGDBPath As String) As IRasterWorkspaceEx
    'FGDBPath string example: c:\data\raster.gdb.
    Dim workspaceFactory As IWorkspaceFactory2=New FileGDBWorkspaceFactoryClass()
    Return CType(workspaceFactory.OpenFromFile(FGDBPath, 0), IRasterWorkspaceEx)
End Function

'Open an ArcSDE workspace as RasterWorkspace.

Public Function OpenSDE(ByVal conString As String) As IRasterWorkspaceEx
    'conString example: SERVER=ais;INSTANCE=9200;VERSION=sde.DEFAULT;USER=raster;PASSWORD=raster.
    Dim workspaceFactory As IWorkspaceFactory2=New SdeWorkspaceFactoryClass()
    Return CType(workspaceFactory.OpenFromString(conString, 0), IRasterWorkspaceEx)
End Function

'Open an accessed workspace as RasterWorkspace.

Public Function OpenAccess(ByVal PGDBPath As String) As IRasterWorkspaceEx
    'FGDBPath string example: c:\data\rasters.mdb.
    Dim workspaceFactory As IWorkspaceFactory2=New AccessWorkspaceFactoryClass()
    Return CType(workspaceFactory.OpenFromFile(PGDBPath, 0), IRasterWorkspaceEx)
End Function

'Open a file workspace as RasterWorkspace.

Public Function OpenFileWorkspace(ByVal wsPath As String) As IRasterWorkspace
    'wsPath example: c:\data\rasters.
    Dim workspaceFact As IWorkspaceFactory=New RasterWorkspaceFactoryClass()
    Return CType(workspaceFact.OpenFromFile(wsPath, 0), IRasterWorkspace)
End Function






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