arcengine栅格渲染(栅格重分类) IRasterClassifyColorRampRenderer

ArcGIS中常用到栅格数据的颜色渲染,以及相应级别的label的显示

private void RasterView(IRasterLayer RasterLayer, double BreakPoint1, double BreakPoint2, double BreakPoint3, double BreakPoint4, double BreakPoint5)
        {
            IRasterClassifyColorRampRenderer ClassifyColor = new RasterClassifyColorRampRendererClass();
            IRasterRenderer RasterRender = ClassifyColor as IRasterRenderer;
            RasterRender.Raster = RasterLayer.Raster;
            RasterRender.Update();

            //断点设置
            ClassifyColor.ClassCount = 6;
            ClassifyColor.set_Break(0, -1);
            ClassifyColor.set_Break(1, BreakPoint1);
            ClassifyColor.set_Break(2, BreakPoint2);
            ClassifyColor.set_Break(3, BreakPoint3);
            ClassifyColor.set_Break(4, BreakPoint4);
            ClassifyColor.set_Break(5, BreakPoint5);
            ClassifyColor.set_Break(6, 1);

            //各个分类的颜色设置
            IFillSymbol Symbol = new SimpleFillSymbolClass() as IFillSymbol;
            Symbol.Color = SetHSVColor(0, 100, 100);
            ClassifyColor.set_Symbol(0, Symbol as ISymbol);
            Symbol.Color = SetHSVColor(25, 100, 100);
            ClassifyColor.set_Symbol(1, Symbol as ISymbol);
            Symbol.Color = SetHSVColor(0, 50, 100);
            ClassifyColor.set_Symbol(2, Symbol as ISymbol);
            Symbol.Color = SetHSVColor(60, 100, 100);
            ClassifyColor.set_Symbol(3, Symbol as ISymbol);
            Symbol.Color = SetHSVColor(90, 50, 100);
            ClassifyColor.set_Symbol(4, Symbol as ISymbol);
            Symbol.Color = SetHSVColor(120, 100, 100);
            ClassifyColor.set_Symbol(5, Symbol as ISymbol);

            RasterLayer.Renderer = RasterRender;

            //label的设置,一定要放在RasterLayer.Renderer = RasterRender这句后面,否则无效
            string str1 = BreakPoint1.ToString();
            string str2 = BreakPoint2.ToString();
            string str3 = BreakPoint3.ToString();
            string str4 = BreakPoint4.ToString(); ;
            string str5 = BreakPoint5.ToString();
            ClassifyColor.set_Label(0, "-1 - " + str1);
            ClassifyColor.set_Label(1, str1 + " - " + str2);
            ClassifyColor.set_Label(2, str2 + " - " + str3);
            ClassifyColor.set_Label(3, str3 + " - " + str4);
            ClassifyColor.set_Label(4, str4 + " - " + str5);
            ClassifyColor.set_Label(5, str5 + " - 1");

            ILayerEffects layereffects = RasterLayer as ILayerEffects;//栅格的半透明显示
            layereffects.Transparency = 50;
        }

总的来说,栅格分类显示总觉得代码十分怪异,一些代码的顺序一定要注意,否则会出很多奇怪的现象,比如出现label小数点后显示出很多0等问题





你可能感兴趣的:(ArcGIS二次开发,ArcGIS二次开发,栅格重分类,栅格颜色渲染)