首页 > 代码库 > 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栅格分类渲染问题解决
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。