How to save a raster to a file format without building pyramids


This sample shows how to save a raster to a file format without building pyramids.

How to use

  1. Call this subroutine from your code.
[VBA]
Sub SaveAsWithoutBuildingPyramids(pRaster As IRaster 'Or as IRasterDataset)
    Dim pSaveAs2 As ISaveAs2
    Set pSaveAs2 = pRaster
    
    Dim pStorageDef As IRasterStorageDef2
    Set pStorageDef = New RasterStorageDef
    
    pStorageDef.PyramidLevel = 0
    
    Dim pWs As IWorkspace
    Set pWs = SetRasterWorkspace("c:\temp")
    
    pSaveAs2.SaveAs "image1.img", pWs, "IMAGINE Image", pStorageDef
    
End Sub


Public Function SetRasterWorkspace(sPath As String) As IRasterWorkspace
    Dim pWsFact As IWorkspaceFactory
    Set pWsFact = New RasterWorkspaceFactory
    Set SetRasterWorkspace = pWsFact.OpenFromFile(sPath, 0)
End Function