zoukankan      html  css  js  c++  java
  • 使用IUniqueValueRenderer在同一层中根据字段渲染出不同颜色收藏

    public static void UniqueValueRenderer(ILayer layer)
      {
       IFeatureLayer pFLayer = layer  as IFeatureLayer;
       IGeoFeatureLayer geoLayer = layer as IGeoFeatureLayer;
       IFeatureClass fcls = pFLayer.FeatureClass;
       IQueryFilter pQueryFilter = new  QueryFilterClass();
       IFeatureCursor fCursor = fcls.Search(pQueryFilter,false);
       IRandomColorRamp rx = new RandomColorRampClass();
       rx.MinSaturation = 15;
       rx.MaxSaturation = 30;
       rx.MinValue = 85;
       rx.MaxValue = 100;
       rx.StartHue = 0;
       rx.EndHue = 360;
       rx.Size =100;
       bool ok;;
       rx.CreateRamp(out ok);
       IEnumColors RColors = rx.Colors;
       RColors.Reset();
       IUniqueValueRenderer pRender = new UniqueValueRendererClass();
       pRender.FieldCount=1;
       pRender.set_Field(0,"乡名");
       IFeature pFeat = fCursor.NextFeature();
       int index = pFeat.Fields.FindField("乡名");
       while(pFeat!=null)
       {
        ISimpleFillSymbol symd = new SimpleFillSymbolClass();
        symd.Style=esriSimpleFillStyle.esriSFSSolid;
        symd.Outline.Width=1;
        symd.Color = RColors.Next();
        string valuestr = pFeat.get_Value(index).ToString();
        pRender.AddValue(valuestr,valuestr,symd as ISymbol);
        pFeat = fCursor.NextFeature();
       }
       geoLayer.Renderer = pRender as IFeatureRenderer;
      }
    版权说明

      如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
      作      者:温景良
      文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

  • 相关阅读:
    lix
    docker-desktop: error during connect
    安装Docker Desktop报错WSL 2 installation is incomplete.
    索引二倒排索引和正排索引
    公众号资料分享
    docker使用物理机gpu运行模型
    使用arthas定位java问题
    pytorch设置gpu
    pytorch模型初始化
    【转】OpenGL图形渲染管线、VBO、VAO、EBO、 TBO概念及用例
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1386955.html
Copyright © 2011-2022 走看看