HOW TO

Build pyramids for raster data using VBA

Last Published: April 25, 2020

Summary

VBA code can loop through all the raster datasets in the specified workspace and build pyramids if necessary.

Procedure



  1. Use a RasterWorkspaceFactory object to create a pointer to the location of the raster data.

    Dim pWorkspaceFactory As IWorkspaceFactory
    Dim pWorkspace As IWorkspace
    Dim pRasterDataset As IRasterDataset
    Dim pEnumDataset As IEnumDataset
    Set pWorkspaceFactory = New RasterWorkspaceFactory
    Set pWorkspace = pWorkspaceFactory.OpenFromFile("d:\data\raster", 0)

  2. Loop through all the raster datasets in the workspace and if pyramids are not present build them.

    Set pEnumDataset = pWorkspace.Datasets(esriDTRasterDataset)
    Set pRasterDataset = pEnumDataset.Next
    Do Until pRasterDataset Is Nothing
    'QI for IRasterPyramid from IRasterDataset
    Dim pRasterPyramid As IRasterPyramid
    Set pRasterPyramid = pRasterDataset
    If pRasterPyramid.Present = False Then
    pRasterPyramid.Create
    MsgBox "Created Pyramid for " & pRasterDataset.CompleteName
    Else
    MsgBox "Pyramid already exists for " & pRasterDataset.CompleteName
    End If
    Set pRasterDataset = pEnumDataset.Next
    Loop

Article ID:000002407

Software:
  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options