Document directory
- Accessing raster workspaces
Accessing raster workspaces
All Geodatabase workspaces support the irasterworkspaceex interface, while file workspaces support irasterworkspace. See the following code example:
[C #]
//Open 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 ArcSDE workspace as RasterWorkspace.static IRasterWorkspaceEx OpenSDE(string conString){ //conString example: SERVER=qian;INSTANCE=9200;VERSION=sde.DEFAULT;USER=raster;PASSWORD=raster. IWorkspaceFactory2 workspaceFactory = new SdeWorkspaceFactoryClass(); return (IRasterWorkspaceEx)workspaceFactory.OpenFromString(conString, 0);}//Open 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 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 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 ArcSDE workspace as RasterWorkspacePublic Function OpenSDE(ByVal conString As String) As IRasterWorkspaceEx 'conString example: SERVER=qian;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 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 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