Rebuild a raster's pyramid?

Discussion created by youngpm on Nov 17, 2011

I've been having a problem getting the pyramid layers of a raster that has been modified to rebuild.  The raster has had some pixels that have been changed, but I can't get the pyramids to work.

The following piece of code throws an exception along the lines of "Failed to build pyramid" when I hit the DeletePyramid command:

/* Convert the ILayer to an IRasterLayer. Note that ApplicationState.CurrentExtractionRasterLayer is an ILayer in my application. */

IRasterLayer irl = ApplicationState.CurrentExtractionRasterLayer as IRasterLayer;

// Rebuild the pyramid layers.
IRasterPyramid3 irp3 = (irl.Raster as IRaster2).RasterDataset as IRasterPyramid3;
irp3.DeletePyramid(); // Exception thrown here!

If I instead call


in place of DeletePyramid(), no exception is thrown, but only the bottom layer of the pyramid is correct!  Any ideas on where I've gone wrong?  I thought that it could be the case that Arc is somehow not allowing itself to overwrite the .ovr file it created when the layer is loaded, but I really have no idea.