首页 > 代码库 > AE栅格分类渲染问题解决

AE栅格分类渲染问题解决

当按照下面方式写代码时,真正的分类break并没有设置成功。注意黑体部分;

 

        public static void ClassifyRenderRaster(IRasterLayer pRasterLayer, int ClassifyNum)        {            IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRenderer() as IRasterClassifyColorRampRenderer;            IRasterRenderer pRRend = pRClassRend as IRasterRenderer;            IRaster pRaster = pRasterLayer.Raster;            IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection;            IRasterBand pRBand = pRBandCol.Item(0);            if (pRBand.Histogram == null)            {                pRBand.ComputeStatsAndHist();            }            pRRend.Raster = pRaster;//this            pRClassRend.ClassCount = ClassifyNum;            pRRend.Update();//this            //省略colorRamp的生成代码            int[] breaks = { 0, 25, 50, 75, 100, 200 };            IFillSymbol fillSymbol = new SimpleFillSymbol() as IFillSymbol;            for (int i = 0; i < pRClassRend.ClassCount; i++)            {                //fillSymbol.Color = colorRamp.get_Color(i);                fillSymbol.Color = GetColor(i);                pRClassRend.set_Symbol(i, fillSymbol as ISymbol);                pRClassRend.set_Break(i, breaks[i]);//this               //pRClassRend.set_Label(i, pRClassRend.get_Break(i).ToString("0.00"));             }                pRasterLayer.Renderer = pRRend //this             }

 

改动后成功。IRasterRenderer.Update须在设置break之后,并且IRasterLayer须赋值为IRasterClassifyColorRampRenderer。

 

        public static void ClassifyRenderRaster(IRasterLayer pRasterLayer, int ClassifyNum)        {            IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRenderer() as IRasterClassifyColorRampRenderer;            IRaster pRaster = pRasterLayer.Raster;            IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection;            IRasterBand pRBand = pRBandCol.Item(0);            if (pRBand.Histogram == null)            {                pRBand.ComputeStatsAndHist();            }            pRClassRend.ClassCount = ClassifyNum;            int[] breaks = { 0, 25, 50, 75, 100, 200 };            IFillSymbol fillSymbol = new SimpleFillSymbol() as IFillSymbol;            for (int i = 0; i < pRClassRend.ClassCount; i++)            {                fillSymbol.Color = colorRamp.get_Color(i);                fillSymbol.Color = GetColor(i);                pRClassRend.set_Symbol(i, fillSymbol as ISymbol);                pRClassRend.set_Break(i, breaks[i]);                //pRClassRend.set_Label(i, pRClassRend.get_Break(i).ToString("0.00"));            }            //IRasterRenderer pRRend = pRClassRend as IRasterRenderer;            //pRRend.Update(); 这两句可以省略            pRasterLayer.Renderer = pRClassRend as IRasterRenderer; //this        }

 

  

开始主要参照这几个,没有解决

AE 栅格图分级渲染 : 参照这里不重新设置break的话(就是不是自定义分类),只设置每个分级的颜色之类的,是可以的,

arcengine栅格渲染(栅格重分类) IRasterClassifyColorRampRenderer :未测试

IRasterClassifyColorRampRenderer 使用时的一些奇怪的地方: 这个顺序不行吧?

AE栅格分类渲染问题解决