Loading to ArcSDE

Created:4/12/2001
Description:

This sample shows the basic steps of loading raster data to an ArcSDE geodatabase.

How to use:
  1. Call the procedures in VB or VBA.
Public Sub LoadToSDE(sDir As String, sInput As String, sServer As String, sInstance As String, _
                      sDB As String, sUser As String, sPasswd As String, sSDERaster As String)
  
   ' sDir: the directory where the input raster resides
  ' sInput: the name of input raster
  ' sServer,sInstance,sDB,sUser,sPasswd: ArcSDE connection info
  ' sSDERaster: the output ArcSDE raster dataset name
   Dim pSDEConn As IRasterSdeConnection
  Dim pSDEStorage As IRasterSdeStorage
  Dim pSDEOp As IRasterSdeServerOperation
  Dim pRasterWsFact As IWorkspaceFactory
  Dim pRasterWs As IRasterWorkspace
  Dim pGeoDs As IGeoDataset
  
   ' Initialize RasterSDELoader
   Set pSDEConn = New RasterSdeLoader
   ' Make connection
   pSDEConn.ServerName = sServer
  pSDEConn.instance = sInstance
  pSDEConn.Database = sDB
  pSDEConn.UserName = sUser
  pSDEConn.Password = sPasswd
  pSDEConn.InputRasterName = sDir & "\" & sInput
  pSDEConn.SdeRasterName = sSDERaster
  
   ' Set storage parameters
   Set pSDEStorage = pSDEConn
   ' Get spatialreference
   Set pRasterWsFact = New RasterWorkspaceFactory
  Set pRasterWs = pRasterWsFact.OpenFromFile(sDir, 0)
  Set pGeoDs = pRasterWs.OpenRasterDataset(sInput)
   ' Set spatialreference
   Set pSDEStorage.SpatialReference = pGeoDs.SpatialReference
   ' Set compression
   pSDEStorage.CompressionType = esriRasterSdeCompressionTypeRunLength
   ' Set tilesize
   pSDEStorage.TileHeight = 128
  pSDEStorage.TileWidth = 128
   ' Pyramids option
   pSDEStorage.PyramidOption = esriRasterSdePyramidBuildWithFirstLevel
  pSDEStorage.PyramidResampleType = RSP_BilinearInterpolation
  
   ' Start loading
   Set pSDEOp = pSDEConn
  pSDEOp.Create
  
   ' Calculate stats
   pSDEOp.ComputeStatistics
  
   ' Cleanup
   Set pSDEConn = Nothing
  Set pSDEStorage = Nothing
  Set pSDEOp = Nothing
  Set pRasterWsFact = Nothing
  Set pRasterWs = Nothing
  Set pGeoDs = Nothing
  
End Sub