[转] ArcEngine 产生专题图

小生原文 ArcEngine 产生专题图

ArcEngine提供多个着色对象用于产生专题图,可以使用标准着色方案,也可以自定义着色方案,ArcEngine提供8中标准着色方案。

一、SimpleRenderer专题图

是使用单一符号进行着色分类,不涉及对要素的数据进行处理。这种专题图同一个图层内的所有元素都是一种符号。

通过SimpleRenderer对象对Symbol进行设置后,赋予IGeoFeatureLayer接口的Renderer属性,对象实现了ITransparencyRenerer接口,通过该接口的属性,可以根据要素的某一个数值字段来设置要素显示的透明度。

该对象还实现了ISimpleRenderer接口,提供了两个重要的属性:Description和Label这两个属性用来设置图例。

/// <summary>
        /// 简单渲染
        /// </summary>
        /// <param name="layerName">图层名字</param>
        /// <param name="FillStyle">FillStyle</param>
        /// <param name="pColor">FillColor</param>
        /// <param name="OutLineColor">OutLineColor</param>
        /// <param name="RenderLabel">样式名称注释</param>
        /// <param name="Descripition">描述</param>
        public void createSimpleFillSymbol(string layerName,esriSimpleFillStyle FillStyle,IColor pColor,IColor OutLineColor,string RenderLabel,string Descripition)
        {
            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            //可以用符号选择器进行
            simpleFillSymbol.Style = FillStyle;
            simpleFillSymbol.Color = pColor;
            //创建边线符号
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            simpleLineSymbol.Color = OutLineColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            simpleFillSymbol.Outline = simpleLineSymbol;

            ISimpleRenderer simpleRender = new SimpleRendererClass();
            simpleRender.Symbol = simpleFillSymbol as ISymbol;
            simpleRender.Label = RenderLabel;
            simpleRender.Description = Descripition;

            IGeoFeatureLayer geoFeatureLayer;
            geoFeatureLayer = getGeoLayer(layerName);
            if (geoFeatureLayer != null)
            {
                geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            }
        }

二、ClassBreakRenderer专题图

为分级专题图,通过要素图层中要素的某个数值字段的值,根据用户要求,将这些值分为多个级别,每个级别用不同的Symbol显示。

该对象实现了IClassBreakRenderer接口,提供了实现分级显示的属性和方法,如Field属性用于设置分级着色的字段,BreakCount属性用于设置分级的数目。

/// <summary>
        /// 分级渲染
        /// </summary>
        /// <param name="layerName">图层名</param>
        /// <param name="classCount">分级数目</param>
        /// <param name="ClassField">分级字段</param>
        /// <param name="FillStyle">填充样式</param>
        public void createClassBreakRender(string layerName, int classCount, string ClassField, esriSimpleFillStyle FillStyle)
        {
            //int classCount = 6;
            ITableHistogram tableHistogram;//表格直方图
            IBasicHistogram basicHistogram;//Provides access to members that control histogram objects created from different data sources. 

            ITable table;
            IGeoFeatureLayer geoFeatureLayer;
            geoFeatureLayer = getGeoLayer(layerName);
            ILayer layer = geoFeatureLayer as ILayer;
            table = layer as ITable;
            tableHistogram = new BasicTableHistogramClass();
            //按照 数值字段分级
            tableHistogram.Table = table;
            tableHistogram.Field = ClassField;
            basicHistogram = tableHistogram as IBasicHistogram;
            object values;
            object frequencys;
            //先统计每个值和各个值出现的次数
            basicHistogram.GetHistogram(out values, out frequencys);
            //创建平均分级对象
            IClassifyGEN classifyGEN = new QuantileClass();
            //用统计结果进行分级 ,级别数目为classCount
            classifyGEN.Classify(values, frequencys, ref classCount);
            //获得分级结果,是个 双精度类型数组
            double[] classes;
            classes = classifyGEN.ClassBreaks as double[];
            //定义不同等级渲染的色带用色
            IEnumColors enumColors = CreateAlgorithmicColorRamp(classes.Length).Colors;
            IColor color;

            IClassBreaksRenderer classBreaksRenderer = new ClassBreaksRendererClass();
            classBreaksRenderer.Field = ClassField;
            classBreaksRenderer.BreakCount = classCount;//分级数目
            classBreaksRenderer.SortClassesAscending = true;//定义分类是否在TOC中显示Legend

            ISimpleFillSymbol simpleFillSymbol;
            for (int i = 0; i < classes.Length - 1; i++)
            {
                color = enumColors.Next();
                simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = color;
                simpleFillSymbol.Style = FillStyle;

                classBreaksRenderer.set_Symbol(i, simpleFillSymbol as ISymbol);
                classBreaksRenderer.set_Break(i, classes[i]);
            }
            if (geoFeatureLayer != null)
            {
                geoFeatureLayer.Renderer = classBreaksRenderer as IFeatureRenderer;
            }

        }

三、UniqueValueRenderer专题图

是依据要素图层中的某个字段的不同值,给每个要素一个单独的颜色,以区分存在的每一个要素。

UniqueValueRenderer实现了IUniqueValueRenderer接口,提供了各种属性和方法,如AddValue方法用于将单个要素的某个字段值和与之相匹配的着色符号加入到UniqueValueRenderer对象。

/// <summary>
        /// 单一值渲染(单字段)
        /// </summary>
        /// <param name="layerName">图层名</param>
        /// <param name="RenderField">渲染字段</param>
        /// <param name="FillStyle">填充样式</param>
        /// <param name="valueCount">字段的唯一值个数</param>
        public void createUniqueValueRander(string layerName, string RenderField, esriSimpleFillStyle FillStyle,int valueCount)
        {
            IGeoFeatureLayer geoFeatureLayer;
            geoFeatureLayer = getGeoLayer(layerName);
            IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
            //可以设置多个字段
            uniqueValueRenderer.FieldCount = 1;//0-3个
            uniqueValueRenderer.set_Field(0, RenderField);

            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Style = FillStyle;

            IFeatureCursor featureCursor = geoFeatureLayer.FeatureClass.Search(null, false);
            IFeature feature;

            if (featureCursor != null)
            {
                IEnumColors enumColors = CreateAlgorithmicColorRamp(valueCount).Colors;
                int fieldIndex = geoFeatureLayer.FeatureClass.Fields.FindField(RenderField);
                for (int i = 0; i < valueCount; i++)
                {
                    feature = featureCursor.NextFeature();
                    string nameValue = feature.get_Value(fieldIndex).ToString();
                    simpleFillSymbol = new SimpleFillSymbolClass();
                    simpleFillSymbol.Color = enumColors.Next();
                    uniqueValueRenderer.AddValue(nameValue, RenderField, simpleFillSymbol as ISymbol);
                }
            }

            geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer;
        }
        /// <summary>
        ///  单一值渲染(多字段)
        /// </summary>
        /// <param name="layerName">图层名</param>
        /// <param name="RenderField">多字段名</param>
        /// <param name="FillStyle">样式</param>
        /// <param name="valueCount">每个字段中唯一值的个数</param>
        public void createUniqueValueRander(string layerName, string[] RenderField, esriSimpleFillStyle FillStyle, int[] valueCount)
        {
            IGeoFeatureLayer geoFeatureLayer;
            geoFeatureLayer = getGeoLayer(layerName);
            IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
            //可以设置多个字段
            uniqueValueRenderer.FieldCount = RenderField .Length;//0-3个
            for (int i = 0; i < RenderField.Length; i++)
            {
                uniqueValueRenderer.set_Field(i, RenderField[i]);
            }

            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Style = FillStyle;

            IFeatureCursor featureCursor = geoFeatureLayer.FeatureClass.Search(null, false);
            IFeature feature;

            if (featureCursor != null)
            {
                for (int i = 0; i < RenderField.Length; i++)
                {
                    IEnumColors enumColors = CreateAlgorithmicColorRamp(valueCount[i]).Colors;
                    int fieldIndex = geoFeatureLayer.FeatureClass.Fields.FindField(RenderField[i]);
                    for (int j = 0; j < valueCount[i]; j++)
                    {
                        feature = featureCursor.NextFeature();
                        string nameValue = feature.get_Value(fieldIndex).ToString();
                        simpleFillSymbol = new SimpleFillSymbolClass();
                        simpleFillSymbol.Color = enumColors.Next();
                        uniqueValueRenderer.AddValue(nameValue, RenderField[i], simpleFillSymbol as ISymbol);
                    }
                }
            }
            geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer;
        }

四、ProportionalSymbolRenderer专题图

使用梯度着色法制作的专题图。

ProportionalSymbolRenderer实现了IProportionalSymbolRenderer接口。

这种着色法需要用户知道最大和最小点各自代表的字段值、着色基于的字段和着色点使用的符号以及它在Legend要出现的级别数目。

/// <summary>
        /// 梯度着色
        /// </summary>
        /// <param name="layerName">图层名字</param>
        /// <param name="ProportionField">要参考的字段</param>
        /// <param name="FillStyle">填充样式</param>
        /// <param name="fillColor">填充Color</param>
        /// <param name="characterMarkerSymbol">特征点符号</param>
        /// <param name="units">参考单位</param>
        /// <param name="pLegendSymbolCount">要分成的级数</param>
        public void createProportionSymbolRender(string layerName, string ProportionField, esriSimpleFillStyle FillStyle, IColor fillColor, ICharacterMarkerSymbol characterMarkerSymbol, esriUnits units, int pLegendSymbolCount)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IFeatureLayer featureLayer;
            IProportionalSymbolRenderer proportionalSymbolRenderer;
            ITable table;
            ICursor cursor;
            IDataStatistics dataStatistics;//用一个字段生成统计数据
            IStatisticsResults statisticsResult;//报告统计数据
            //stdole.IFontDisp fontDisp;//定义字体

            geoFeatureLayer = getGeoLayer(layerName);
            featureLayer = geoFeatureLayer as IFeatureLayer;
            table = geoFeatureLayer as ITable;
            cursor = table.Search(null, true);
            dataStatistics = new DataStatisticsClass();
            dataStatistics.Cursor = cursor;
            dataStatistics.Field = ProportionField;//确定分级字段
            statisticsResult = dataStatistics.Statistics;
            if (statisticsResult != null)
            {
                IFillSymbol fillSymbol = new SimpleFillSymbolClass();
                fillSymbol.Color = fillColor;
                //ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbolClass();
                //fontDisp = new stdole.StdFontClass() as stdole.IFontDisp;
                //fontDisp.Name = "arial";
                //fontDisp.Size = 20;
                //characterMarkerSymbol.Font = fontDisp;
                //characterMarkerSymbol.CharacterIndex = 90;
                //characterMarkerSymbol.Color = getRGB(255, 0, 0);
                //characterMarkerSymbol.Size = 8;
                proportionalSymbolRenderer = new ProportionalSymbolRendererClass();
                proportionalSymbolRenderer.ValueUnit = units;
                proportionalSymbolRenderer.Field = ProportionField ;
                proportionalSymbolRenderer.FlanneryCompensation = false;//分级是不是在TOC中显示legend
                proportionalSymbolRenderer.MinDataValue = statisticsResult.Minimum;
                proportionalSymbolRenderer.MaxDataValue = statisticsResult.Maximum;
                proportionalSymbolRenderer.BackgroundSymbol = fillSymbol;
                proportionalSymbolRenderer.MinSymbol = characterMarkerSymbol as ISymbol;
                proportionalSymbolRenderer.LegendSymbolCount = pLegendSymbolCount;//要分成的级数
                proportionalSymbolRenderer.CreateLegendSymbols();
                geoFeatureLayer.Renderer = proportionalSymbolRenderer as IFeatureRenderer;
            }
        }

五、ChartRenderer专题图

使用一个饼图或柱图来表示一个要素的多个属性。有水平排列和累计排列两种。

ChartRenderer对象实现了IChartRenderer接口,其中ChartSymbol方法用于设置着色对象的着色符号,Label属性用于设置Legend的标签。

该方法用于比较一个要素中不同属性,在获得着色图层的单个或多个字段时用RendererField对象来操作。该类实现了IRendererField接口,可以通过AddField方法来添加字段。

该着色法是使用饼图来表现要素的多个属性之间的比率关系。该对象实现了IPicChartRenderer接口,使用PieChartSymbol符号来修饰要素。

/// <summary>
        /// 条状图渲染
        /// </summary>
        /// <param name="layerName">图层名字</param>
        /// <param name="RenderField">要柱状表示的字段</param>
        /// <param name="fillsymbolColor">这些字段分别需要渲染的颜色</param>
        /// <param name="BarWidth">每个柱子的宽度</param>
        /// <param name="BgColor">背景色</param>
        public void createBarChartSymbol(string layerName, string[] RenderField, IColor[] fillsymbolColor,double BarWidth,IColor BgColor)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IFeatureLayer featureLayer;
            ITable table;
            ICursor cursor;
            IRowBuffer rowBuffer;
            //获取渲染图层
            geoFeatureLayer = getGeoLayer(layerName);
            featureLayer = geoFeatureLayer as IFeatureLayer;
            table = featureLayer as ITable;
            geoFeatureLayer.ScaleSymbols = true;
            IChartRenderer chartRenderer = new ChartRendererClass();
            IRendererFields rendererFields = chartRenderer as IRendererFields;
            for (int i = 0; i < RenderField.Length; i++)
            {
                rendererFields.AddField(RenderField[i], RenderField[i]);
            }

            //int[] fieldIndexs = new int[2];
            //fieldIndexs[0] = table.FindField(field1);
            //fieldIndexs[1] = table.FindField(field2);
            //获取要素最大值,决定柱子的最大高度
            double fieldValue = 0.0, maxValue = 0.0;
            cursor = table.Search(null, true);
            rowBuffer = cursor.NextRow();
            while (rowBuffer != null)
            {
                for (int i = 0; i < RenderField.Length; i++)
                {
                    int index = table.FindField(RenderField[i]);
                    fieldValue = double.Parse(rowBuffer.get_Value(index).ToString());
                    if (fieldValue > maxValue)
                    {
                        maxValue = fieldValue;
                    }
                }
                rowBuffer = cursor.NextRow();
            }
            //创建水平排列符号
            IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
            barChartSymbol.Width = BarWidth;//柱子的边长
            IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
            markerSymbol.Size = 50;//这个是?
            IChartSymbol chartSymbol = barChartSymbol as IChartSymbol;
            chartSymbol.MaxValue = maxValue;
            //添加渲染符号
            ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
            IFillSymbol[] fillsymbol = new IFillSymbol[RenderField.Length];
            for (int i = 0; i < RenderField.Length; i++)
            {
                //设置不同颜色的柱子
                fillsymbol[i] = new SimpleFillSymbolClass();
                fillsymbol[i].Color = fillsymbolColor[i];
                symbolArray.AddSymbol(fillsymbol[i] as ISymbol);
                //IFillSymbol fillSymbol = new SimpleFillSymbolClass();
                //fillSymbol.Color = getRGB(255, 0, 0);//红色柱子
                //symbolArray.AddSymbol(fillSymbol as ISymbol);
                //fillSymbol = new SimpleFillSymbolClass();
                //fillSymbol.Color = getRGB(0, 255, 0);//绿色柱子
                //symbolArray.AddSymbol(fillSymbol as ISymbol);
            }

            //设置柱状图符号
            chartRenderer.ChartSymbol = barChartSymbol as IChartSymbol;
            //设置底图样式
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            pFillSymbol.Color = BgColor;
            chartRenderer.BaseSymbol = pFillSymbol as ISymbol;
            chartRenderer.UseOverposter = false;//假如那个位置放不下柱状图,是否用线段连接指示位置
            //创建图例
            chartRenderer.CreateLegend();
            geoFeatureLayer.Renderer = chartRenderer as IFeatureRenderer;
        }
        /// <summary>
        /// 创建累计柱状图表(stacked)
        /// </summary>
        /// <param name="layerName">Name</param>
        /// <param name="RenderField">Fields</param>
        /// <param name="fillsymbolColor">every Color</param>
        /// <param name="BarWidth">width</param>
        /// <param name="BgColor">BackGound Color</param>
        public void createStackedChartSymbol(string layerName, string[] RenderField, IColor[] fillsymbolColor, double BarWidth, IColor BgColor)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IFeatureLayer featureLayer;
            ITable table;
            ICursor cursor;
            IRowBuffer rowBuffer;
            //获取渲染图层
            geoFeatureLayer = getGeoLayer(layerName);
            featureLayer = geoFeatureLayer as IFeatureLayer;
            table = featureLayer as ITable;
            geoFeatureLayer.ScaleSymbols = true;
            IChartRenderer chartRenderer = new ChartRendererClass();
            IRendererFields rendererFields = chartRenderer as IRendererFields;
            for (int i = 0; i < RenderField.Length; i++)
            {
                rendererFields.AddField(RenderField[i], RenderField[i]);
            }
            //获取要素最大值
            double fieldValue = 0.0, maxValue = 0.0;
            cursor = table.Search(null, true);
            rowBuffer = cursor.NextRow();
            while (rowBuffer != null)
            {
                for (int i = 0; i < RenderField.Length ; i++)
                {
                    int index = table.FindField(RenderField[i]);
                    fieldValue = double.Parse(rowBuffer.get_Value(index).ToString());
                    if (fieldValue > maxValue)
                    {
                        maxValue = fieldValue;
                    }
                }
                rowBuffer = cursor.NextRow();
            }
            //创建累积排列符号
            IStackedChartSymbol stackedChartSymbol = new StackedChartSymbolClass();

            stackedChartSymbol.Width = 10;//柱子宽度
            IMarkerSymbol markerSymbol = stackedChartSymbol as IMarkerSymbol;
            markerSymbol.Size = 50;//下面的大小
            IChartSymbol chartSymbol = stackedChartSymbol as IChartSymbol;
            chartSymbol.MaxValue = maxValue;
            //添加渲染符号
            ISymbolArray symbolArray = stackedChartSymbol as ISymbolArray;
            IFillSymbol[] fillsymbol = new IFillSymbol[RenderField.Length];
            for (int i = 0; i < RenderField.Length; i++)
            {
                //设置不同颜色的柱子
                fillsymbol[i] = new SimpleFillSymbolClass();
                fillsymbol[i].Color = fillsymbolColor[i];
                symbolArray.AddSymbol(fillsymbol[i] as ISymbol);
            }
            //设置柱状图符号
            chartRenderer.ChartSymbol = stackedChartSymbol as IChartSymbol;
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            pFillSymbol.Color =BgColor;
            chartRenderer.BaseSymbol = pFillSymbol as ISymbol;
            chartRenderer.UseOverposter = false;
            //创建图例
            chartRenderer.CreateLegend();
            geoFeatureLayer.Renderer = chartRenderer as IFeatureRenderer;
        }
        /// <summary>
        /// 创建饼图
        /// </summary>
        /// <param name="layerName">name</param>
        /// <param name="RenderField">Fields</param>
        /// <param name="fillsymbolColor">Each color</param>
        /// <param name="BgColor">background Color</param>
        public void createPieChartSymbol(string layerName, string[] RenderField, IColor[] fillsymbolColor,  IColor BgColor)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IFeatureLayer featureLayer;
            ITable table;
            ICursor cursor;
            IRowBuffer rowBuffer;

            //获取渲染图层
            geoFeatureLayer = getGeoLayer(layerName);
            featureLayer = geoFeatureLayer as IFeatureLayer;
            table = featureLayer as ITable;
            geoFeatureLayer.ScaleSymbols = true;
            IChartRenderer chartRenderer = new ChartRendererClass();
            IPieChartRenderer pieChartRenderer = chartRenderer as IPieChartRenderer;
            IRendererFields rendererFields = chartRenderer as IRendererFields;
            for (int i = 0; i < RenderField.Length; i++)
            {
                rendererFields.AddField(RenderField[i], RenderField[i]);

            }
            //获取渲染要素的最大值
            double fieldValue = 0.0, maxValue = 0.0;
            cursor = table.Search(null, true);
            rowBuffer = cursor.NextRow();
            while (rowBuffer != null)
            {
                for (int i = 0; i < RenderField.Length ; i++)
                {
                    int index = table.FindField(RenderField[i]);
                    fieldValue = double.Parse(rowBuffer.get_Value(index).ToString());
                    if (fieldValue > maxValue)
                    {
                        maxValue = fieldValue;
                    }
                }
                rowBuffer = cursor.NextRow();
            }
            //设置饼图符号
            IPieChartSymbol pieChartSymbol = new PieChartSymbolClass();
            pieChartSymbol.Clockwise = true;
            pieChartSymbol.UseOutline = true;
            IChartSymbol chartSymbol = pieChartSymbol as IChartSymbol;
            chartSymbol.MaxValue = maxValue;
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();
            lineSymbol.Color = getRGB(255, 0, 0);
            lineSymbol.Width = 2;
            pieChartSymbol.Outline = lineSymbol;
            IMarkerSymbol markerSymbol = pieChartSymbol as IMarkerSymbol;
            markerSymbol.Size = 30;
            //添加渲染符号
            ISymbolArray symbolArray = pieChartSymbol as ISymbolArray;
            IFillSymbol[] fillsymbol =new  IFillSymbol[RenderField.Length];
            for (int i = 0; i < RenderField.Length; i++)
            {
                fillsymbol[i] = new SimpleFillSymbolClass();
                fillsymbol[i].Color = fillsymbolColor[i];
                symbolArray.AddSymbol(fillsymbol[i] as ISymbol);
            }
            //设置背景
            chartRenderer.ChartSymbol = pieChartSymbol as IChartSymbol;
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            pFillSymbol.Color = BgColor;
            chartRenderer.BaseSymbol = pFillSymbol as ISymbol;
            chartRenderer.UseOverposter = false;
            //创建图例
            chartRenderer.CreateLegend();
            geoFeatureLayer.Renderer = chartRenderer as IFeatureRenderer;
        }

六、DotDensityRenderer专题图

DotDensityRenderer对象使用DotDensityFillSymbol符号对Polygon类型的要素进行着色。该专题图使用随机分布的点的密度来表现要素某个属性值得大小。也可以对图层的多个属性值着色,通过指定不同的点符号来区分。

DotDensityRenderer对象实现IDotDensityRenderer接口,定义了使用点密度着色方法和属性,如DotDensitySymbol用于确定着色点符号,CreateLegend方法用于产生图例。

/// <summary>
        /// 点密度
        /// </summary>
        /// <param name="layerName">图层名字</param>
        /// <param name="RenderField">渲染字段</param>
        /// <param name="dotDensityFillSymbol">点密度符号</param>
        /// <param name="simpleMarkerSymbol">点符号</param>
        /// <param name="RenderDensity">点密度</param>
        public void createDotDensityFillSymbol(string layerName, string RenderField, IDotDensityFillSymbol dotDensityFillSymbol, ISimpleMarkerSymbol simpleMarkerSymbol,double  RenderDensity)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IDotDensityRenderer dotDensityRenderer;
            //获取渲染图层
            geoFeatureLayer = getGeoLayer(layerName);
            dotDensityRenderer = new DotDensityRendererClass();
            IRendererFields rendererFields = dotDensityRenderer as IRendererFields;
            //设置渲染字段
            rendererFields.AddField(RenderField, RenderField);

            ////设置填充颜色和背景色,直接由参数传入,具体定义参考下面的 例子
            //dotDensityFillSymbol = new DotDensityFillSymbolClass();
            //dotDensityFillSymbol.DotSize = 3;
            //dotDensityFillSymbol.Color = getRGB(255, 0, 0);
            //dotDensityFillSymbol.BackgroundColor = getRGB(0, 255, 0);

            //设置渲染符号
            ISymbolArray symbolArray = dotDensityFillSymbol as ISymbolArray;
            //点符号样式,也可以参考下面的自己定义
            //ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            //simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            //simpleMarkerSymbol.Size = 2;
            //simpleMarkerSymbol.Color = getRGB(0, 0, 255);
            symbolArray.AddSymbol(simpleMarkerSymbol as ISymbol);
            dotDensityRenderer.DotDensitySymbol = dotDensityFillSymbol;
            //设置渲染密度
            dotDensityRenderer.DotValue = RenderDensity;
            //创建图例
            dotDensityRenderer.CreateLegend();
            geoFeatureLayer.Renderer = dotDensityRenderer as IFeatureRenderer;
        }

此外还有两个补充方法(在调用这些方法的时候能用到):

private IMap pMap;
        public Renderer(IMap _pMap)
        {
            pMap = _pMap;
        }
        //获取颜色对象
        private IRgbColor getRGB(int r, int g, int b)
        {
            IRgbColor pColor;
            pColor = new RgbColorClass();
            pColor.Red = r;
            pColor.Green = g;
            pColor.Blue = b;
            return pColor;
        }
        private IGeoFeatureLayer getGeoLayer(string layerName)
        {
            ILayer layer;
            IGeoFeatureLayer geoFeatureLayer;
            for (int i = 0; i < this.pMap.LayerCount; i++)
            {
                layer = this.pMap.get_Layer(i);
                if (layer != null && layer.Name == layerName)
                {
                    geoFeatureLayer = layer as IGeoFeatureLayer;
                    return geoFeatureLayer;
                }
            }
            return null;
        }

时间: 2024-11-25 15:00:08

[转] ArcEngine 产生专题图的相关文章

ae专题图

点密度图.分层设色图/等级图.单值图.柱状图.饼状图的实现代码 C# private void 点密度图ToolStripMenuItem_Click(object sender, EventArgs e)        {            //获取当前图层 ,并把它设置成IGeoFeatureLayer的实例             IMap pMap = axMapControl1.Map;            ILayer pLayer = pMap.get_Layer(0) as

用ARCGIS配出一张DEM专题图

专题图是指突出而尽可能完善.详尽地表达制图区内的一种或几种自然或社会经济要素的地图.专题图的制图领域宽广,凡具有空间属性的信息数据都可以用其来表示.由于DEM描述的是地面高程信息,它在测绘.水文.气象.地貌.地质.土壤.工程建设. 通讯.军事等国民经济和国防建设以及人文和自然科学领域有着广泛的应用.本文介绍一下在arcgis中如何对DEM进行专题图配图.本文需要用的软件工具有两个:本文需要用的软件工具有2个,第一款要用的软件是locaspace viewer,该软件集成了Google Earth

一幅专题地图有哪些内容?(范围分段专题图)

标题(主标题一般由:指标名,时间组成) 图例 段数:2-9段,最经常使用5-6段 分段颜色: 随机单值 qualitative(分类.如地区的少数民族人口最多的表示 双色(定性. 如两党竞选:红黑) 单色渐变 sequential(同色系.一般用于反映从小到大的正数) 双色渐变 diverging(二分型.常见于用颜色区分正负值.平均值上下) 标注平均值(在图例中区块间画一条横线标注所有地区的平均水平,此平均值也经常作为分段值) 特殊值:无数据(无值).数据不可用.经常使用灰色.白色和斜线填充.

leaflet之唯一值渲染专题图

leaflet之唯一值渲染专题图 点击查看www.giserdqy.comleaflet之唯一值渲染专题图 初始化地图,添加底图 自定义显示信息的L.control,也可以设置popup弹出框 初始化图层,设置style,onEachFeature要素绑定 创建图例var legend = L.control 渲染关键方法 根据属性范围设置渲染颜色 图层样式 根据要素属性设置特殊渲染样式 重置要素样式 缩放到要素范围 map.fitBounds(e.target.getBounds()); 每个

arcengine 开发经典帖 【强烈推荐仔细研读】

转自原文 arcengine 开发经典帖 使用ArcGIS Engine 开发自定义GIS应用: 第一部分:使用ArcGIS Engine 发布自定义GIS应用软件-全面了解ArcGIS Engine的产品. 第二部分:ArcEngine9.2的新特性及变化.(续)--类对比及变化.(续)--(代码转换插件).(续)--ArcEngine新命令,工具.菜单和面板 第三部分:使用 ArcGIS Engine开发应用程序(自定义或嵌入) 第四部分:开发Engine 应用程序的基本原理.(续).(续)

arcpy.mapping实战-专题图制图自动化

by 李远祥 最初对arcpy.mapping感兴趣是因为一次大规模的专题地图调整的需要,由于某某单位利用ArcEngine编写的专题图出图系统,出现了一些小问题,导致地图整饰元素的位置出现了误差.由于最终的生产任务已经到了尾声才发现一些问题,所以需要在出图系统之外使用ArcMap进行修改,这样针对上千幅成果文档进行修改,是个不小的工作量.后来决定使用arcpy.mapping,使用Python进行递归查询mxd文档,最终实现自动化修改和重新出图.虽然当时只是使用了很少的功能,基本上就是对整饰元

ArcGIS Engine开发前基础知识(1)

ArcGIS二次开发是当前gis领域的一项重要必不可少的技能.下面介绍它的基本功能 一.ArcGIS Engine功能 在使用之前首先安装和部署arcgis sdk,(在这里不在赘述相关知识)可以实现的功能主要有地图的基本操作.信息查询.专题地图制作.数据编辑.网络分析.空间统计分析.三维分析等. 1.地图的基本操作 地图的基本操作主要包括加载矢量.栅格数据,浏览缩放地图,保存地图,在地图上显示文本注记,绘制点线面几何体等. 2.信息查询 信息查询主要通过矩形圆形或多边形来选中地图上的要素,或者

ArcGIS Engine渲染

符号化之Renderer( 渲染)体系 ArcGIS Engine9.3对GIS数据的符号化分为矢量数据渲染和栅格数据渲染两大类.接下来分别介绍FeatureRender和RasterRender. 1.FeatureRender对象    FeatureRenderer是一个抽象类,它有15个子类负责进行不同类型的着色运算.它们都实现了IFeatureRenderer接口,这个接口定义了进行要素图层符号化的公共属性和方法.    可以通过IGeoFeatureLayer::Renderer属性

安装Team Foundation Server 2012过程截图

原文:安装Team Foundation Server 2012过程截图 专题图 1,下载Team Foundation Server 2012  官方下载: http://www.microsoft.com/visualstudio/11/zh-cn/downloads 请单击"Team Foundation Server(团队基础服务器)",下载 单击"fts_server"安装. 1, 2, 3, 4, 5, 5_2, 5-3, 5-4, 5-5, 5-6,