Should be a simple IRasterLayer question...

1778
0
02-14-2012 06:09 PM
DonaldBrandon1
New Contributor
Given that I have a valid raster "mExtractedraster"...


IRasterLayer rasterLayer = new RasterLayerClass();
rasterLayer.CreateFromRaster(mExtractedRaster);

// Customize how the raster renders.
IRasterStretchColorRampRenderer mRenderer = new RasterStretchColorRampRenderer();
mRenderer.ColorScheme = "Blue Light to Dark";

rasterLayer.Renderer = (IRasterRenderer)mRenderer;

// Compute the statistics for the raster.
IRasterCalcStatsHistogram m_calcStats = new RasterCalcStatsHistogramClass();
IStatsHistogram m_stHisto = new StatsHistogramClass();

m_calcStats.ComputeFromRaster(rasterLayer.Raster, 1, m_stHisto);
                                    
mapControl.AddLayer(rasterLayer);
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);



...this code should correctly display the raster layer in the map control using the correct renderer.  If I use the identify tool to explore the raster layer, I am getting the correct cell values however the raster looks like one that does not contain any statistics.

Ideas?  Thanks.
0 Kudos
0 Replies