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 |
---|---|
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
Engine Developer Kit | Engine Runtime |