GP工具IDW执行后,生成的栅格图层是黑白二色,需要手动进行分级渲染,似乎不是所有栅格图层都可以进行分级渲染,注意异常处理。注意ARCMAP中是有颜色的,无需自己处理。
IRasterClassifyColorRampRenderer pClassRender = new RasterClassifyColorRampRendererClass(); IRasterRenderer pRasterRender = pClassRender as IRasterRenderer; pRasterRender.Raster = rl.Raster; pClassRender.ClassCount = 10; ////分10级 pRasterRender.Update(); IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass(); IRgbColor startColor = new RgbColorClass(); IRgbColor endColor = new RgbColorClass(); ////自己选颜色吧 startColor.Red = 225; startColor.Green = 0; startColor.Blue = 128; pRamp.FromColor = startColor as IColor; endColor.Red = 135; endColor.Green = 42; endColor.Blue = 8; pRamp.ToColor = endColor as IColor; pRamp.Size = 10; bool ok = true; pRamp.CreateRamp(out ok); ISimpleFillSymbol pFillSymbo = new SimpleFillSymbolClass(); for (int i = 0; i < 10; i++) { pFillSymbo.Color = pRamp.get_Color(i); pClassRender.set_Symbol(i, pFillSymbo as ISymbol); pClassRender.set_Label(i, Convert.ToString(i + 1)); } pRasterRender.Update(); rl.Renderer = pClassRender as IRasterRenderer; map.AddLayer(rl as ILayer);