通过SDE将栅格图像导入到数据为中

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
On Error GoTo eh
    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 = esriRasterSdeCompressionTypeUncompressed
    ' Set tilesize
    pSDEStorage.TileHeight = 128
    pSDEStorage.TileWidth = 128
    ' Pyramids option
    pSDEStorage.PyramidOption = esriRasterSdePyramidBuildWithFirstLevel
    pSDEStorage.PyramidResampleType = RSP_BilinearInterpolation
    pSDEStorage.CompressionType = esriRasterSdeCompressionTypeJPEG2000
   
    ' Start loading
    Set pSDEOp = pSDEConn
   
    pSDEOp.Create
    pSDEOp.Update
    ' Calculate stats
    pSDEOp.ComputeStatistics
   
    ' Cleanup
    Set pSDEConn = Nothing
    Set pSDEStorage = Nothing
    Set pSDEOp = Nothing
    Set pRasterWsFact = Nothing
    Set pRasterWS = Nothing
    Set pGeoDs = Nothing
   
Exit Sub
eh:
    MsgBox Err.Description, vbInformation, "LoadToSDE" '错误处理

End Sub


你可能感兴趣的:(arcsde)