AE栅格分类渲染问题解决
Posted GIS MAN
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AE栅格分类渲染问题解决相关的知识,希望对你有一定的参考价值。
一个0-255的波段图像,要分为三类,0-85,85-170,170-255,那么这个断点其实有四个,分别是0,85,170,255
当按照下面方式写代码时,真正的分类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的话(就是不是自定义分类),只设置每个分级的颜色之类的,是可以的,
以上是关于AE栅格分类渲染问题解决的主要内容,如果未能解决你的问题,请参考以下文章
GDALGDAL栅格数据结构学习笔记: 关于Metadata
World Wind Java开发之十——AnalyticSurface栅格渲染(转)