ArcGIS Engine 10 开发手册(8-25)分级渲染

本文目录
  • 正文

本文通过代码演示如何进行分级渲染。

示例代码

public IRasterRenderer ClassifyRenderer (ESRI.ArcGIS.Geodatabase.IRasterDataset pRasterDataset)

{

  try

  {

    //Create the classify renderer. 
    IRasterClassifyColorRampRenderer pClassifyRenderer = new RasterClassifyColorRampRendererClass ();

    IRasterRenderer pRasterRenderer = (IRasterRenderer) pClassifyRenderer;

    //Set up the renderer properties.

    IRaster pRaster = pRasterDataset.CreateDefaultRaster ();
    pRasterRenderer.Raster = pRaster;
    pClassifyRenderer.ClassCount = 9;
    pRasterRenderer.Update ();

    IRgbColor pFromColor = new RgbColorClass ();
    pFromColor.Red = 255;

    pFromColor.Green = 0;

    pFromColor.Blue = 0;

    IRgbColor pToColor = new RgbColorClass ();
    pToColor.Red = 0;

    pToColor.Green = 255;

    pToColor.Blue = 255;

    //Set the color ramp for the symbology.

    IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass ();
    pRamp.Size = 9;

    pRamp.FromColor = pFromColor;
    pRamp.ToColor = pToColor;
    bool pBoolColorRamp;

    pRamp.CreateRamp (out pBoolColorRamp);

    //Create the symbol for the classes.

    IFillSymbol pFillSymbol = new SimpleFillSymbolClass ();
    for (int i = 0; i < pClassifyRenderer.ClassCount; i++)

    {

      pFillSymbol.Color = pRamp.get_Color (i);
      pClassifyRenderer.set_Symbol (i,(ISymbol) pFillSymbol);
      pClassifyRenderer.set_Label (i, Convert.ToString (i));

    }

    return pRasterRenderer;

  } catch (Exception ex)

  {

    System.Diagnostics.Debug.WriteLine (ex.Message);
    return null;

  }

}

ArcGIS Engine 10 开发手册全集

ArcGIS Engine 10 开发手册全集: ArcGIS Engine 10 开发手册

如果本文对你有所帮助,欢迎对我们团队进行打赏捐助,让我们在传播3S的路上可以走得更远。
赞赏支持
微信捐助麻辣GIS 支付宝捐助麻辣GIS

麻辣GIS-Sailor
作者:
GIS爱好者,学GIS,更爱玩GIS。

如您有疑问,可在文末留言,或到QQ群提问。

本站QQ群(一):291616564 麻辣GIS

本站QQ群(二):166408035 麻辣GIS(二)

微信公众号:malagis,扫描右边二维码直接关注。

发表评论