点密度图、分层设色图/等级图、单值图、柱状图、饼状图的实现代码 C#

private void 点密度图ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 
            IMap pMap = axMapControl1.Map;
            ILayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

//获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature pFeature = pFeatureCursor.NextFeature();

///////////////////////
           
            ///////////////////////////////////////////////////////////////////
            //定义点密度图渲染组件
            IDotDensityRenderer DotDensityRenderer = new DotDensityRendererClass();

//定义点密度图渲染组件对象的渲染字段对象
            IRendererFields flds = (IRendererFields)DotDensityRenderer;
            flds.AddField("FID", "FID");
            //flds.AddField("Shape", "Shape");

//定义点密度图渲染得符号对象
            IDotDensityFillSymbol ddSym = new DotDensityFillSymbolClass();
            IRgbColor BackColor = new RgbColorClass();
            BackColor.Red = 234;
            BackColor.Blue = 128;
            BackColor.Green = 220;
            IRgbColor SymbolColor = new RgbColorClass();
            SymbolColor.Red = 234;
            SymbolColor.Blue = 128;
            SymbolColor.Green = 220;
            ////点密度图渲染背景颜色
            //ddSym.BackgroundColor = BackColor;
            ddSym.DotSize =8;
            ddSym.FixedPlacement = true;
            //ddSym.Color = SymbolColor;
            ILineSymbol pLineSymbol=new CartographicLineSymbolClass();
            ddSym.Outline = pLineSymbol;

//定义符号数组 
            ISymbolArray symArray = (ISymbolArray)ddSym;
            //添加点密度图渲染的点符号到符号数组中去
            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
            pMarkerSymbol.Style. = esriSimpleMarkerStyle.esriSMSCircle;
            pMarkerSymbol.Size = 2;
            pMarkerSymbol.Color = SymbolColor;;
           
            
            symArray.AddSymbol(pMarkerSymbol as ISymbol );
                  
            //设置点密度图渲染的点符号
                    //DotDensityRenderer.DotDensitySymbol =symArray;
               DotDensityRenderer.DotDensitySymbol = ddSym;
            //确定一个点代表多少值
                    DotDensityRenderer .DotValue=0.2;
            //点密度渲染采用的颜色模式
                    DotDensityRenderer.ColorScheme = "Custom";
            //创建点密度图渲染图例
                    DotDensityRenderer.CreateLegend();
            //设置符号大小是否固定
                    DotDensityRenderer.MaintainSize = true;
            //将点密度图渲染对象与渲染图层挂钩
                    pGeoFeatureLayer.Renderer = (IFeatureRenderer)DotDensityRenderer;
            //刷新地图和TOOCotrol
                    IActiveView pActiveView = axMapControl1.Map as IActiveView;
                    pActiveView.Refresh();
                    axTOCControl1.Update();
                
        }
private void 分层设色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            
            //获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 
            IMap pMap = axMapControl1.Map;
            ILayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;
            
            
            //获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature pFeature = pFeatureCursor.NextFeature();
           
           
            //
            IFeatureRenderer PR=pGeoFeatureLayer.Renderer;
           
           
            //JoinData("县级区域", "DZGB", "sectioncode");   //join外部表
           // int DC ;  
            int  desiredClasses = 5;
            string fieldName = "AREA";
            int classesCount;
            double[] classes;
            string strOutput = "";
            bool ok;
            object dataFrequency;
            object dataValues;
            ITable pTable ;
            //IClassify pClassify;
            EqualIntervalClass pClassify;
            //IBasicHistogram pTableHistogram = new BasicTableHistogramClass();
            //IHistogram pTableHistogram = new BasicTableHistogramClass();
            ITableHistogram pTableHistogram = new BasicTableHistogramClass() as ITableHistogram;
            IBasicHistogram pHistogram;
            IClassBreaksRenderer pClassBreaksRenderer;
            IHsvColor pFromColor;
            IHsvColor pToColor;
            IAlgorithmicColorRamp pAlgorithmicColorRamp;
            IEnumColors pEnumColors;
            IColor pColor;
            ISimpleFillSymbol pSimpleFillSymbol;

pLayer = (IFeatureLayer)axMapControl1.get_Layer(0);
            pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;
            pTable = (ITable)pGeoFeatureLayer;
            pHistogram = (IBasicHistogram)pTableHistogram;
            // Get values and frequencies for the field
            pTableHistogram.Field = fieldName;
            pTableHistogram.Table = pTable;
            pHistogram.GetHistogram(out dataValues, out dataFrequency);
            // Put values and frequencies into an Equal Interval Classify Object
            pClassify = new EqualIntervalClass();
            //pClassify = new NaturalBreaksClass();
            pClassify.SetHistogramData(dataValues, dataFrequency);
            pClassify.Classify(dataValues, dataFrequency, ref desiredClasses);
            //pClassify.Classify(ref desiredClasses);
            classes = (double[])pClassify.ClassBreaks;
            classesCount = classes.Length;

// Initialise a new Class Breaks renderer
            // Supply the number of Class Breaks and the field to perform. the class breaks on
            pClassBreaksRenderer = new ClassBreaksRendererClass();
            pClassBreaksRenderer.Field = fieldName;
            pClassBreaksRenderer.BreakCount = classesCount;
            pClassBreaksRenderer.SortClassesAscending = true;
            // Use algorithmic color ramp to generate an range of colors between YELLOW to RED
            // Initial color: YELLOW
            pFromColor = new HsvColorClass();
            pFromColor.Hue = 60;
            pFromColor.Saturation = 100;
            pFromColor.Value = 96;
            // Final color: RED
            pToColor = new HsvColorClass();
            pToColor.Hue = 0;
            pToColor.Saturation = 100;
            pToColor.Value = 96;
            // Set up HSV Color ramp to span from YELLOW to RED
            pAlgorithmicColorRamp = new AlgorithmicColorRampClass();
            pAlgorithmicColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAlgorithmicColorRamp.FromColor = pFromColor;
            pAlgorithmicColorRamp.ToColor = pToColor;
            pAlgorithmicColorRamp.Size = classesCount;
            pAlgorithmicColorRamp.CreateRamp(out ok);

pEnumColors = pAlgorithmicColorRamp.Colors;
            for (int index = 0; index < classesCount - 1; index++)
            {
                pColor = pEnumColors.Next();
                pSimpleFillSymbol = new SimpleFillSymbolClass();
                pSimpleFillSymbol.Color = pColor;
                pSimpleFillSymbol.Style. = esriSimpleFillStyle.esriSFSSolid;
                pClassBreaksRenderer.set_Symbol(index, (ISymbol)pSimpleFillSymbol);
                pClassBreaksRenderer.set_Break(index, classes[index + 1]);
                // Store each break value for user output
                strOutput += "-" + classes[index + 1] + "/n";
            }
            pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
            //this.axMapControl1.Refresh();
           /////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////
            
            //get the custom property from which is supposed to be the layer to be saved
            object customProperty = null;
            //IMapControl3 mapControl = null;
            customProperty = axMapControl1.CustomProperty;
           
            //ask the user to set a name for the new layer file
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Layer File|*.lyr|All Files|*.*";
            saveFileDialog.Title = "生成专题图";
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.FileName = System.IO.Path.Combine(saveFileDialog.InitialDirectory, pGeoFeatureLayer.Name + ".lyr");

//get the layer name from the user
            DialogResult dr = saveFileDialog.ShowDialog();
            if (saveFileDialog.FileName != "" && dr == DialogResult.OK)
            {
                if (System.IO.File.Exists(saveFileDialog.FileName))
                {
                    //try to delete the existing file
                    System.IO.File.Delete(saveFileDialog.FileName);
                }

//create a new LayerFile instance
                ILayerFile layerFile = new LayerFileClass();
                //create a new layer file
                layerFile.New(saveFileDialog.FileName);
                //attach the layer file with the actual layer
                layerFile.ReplaceContents((ILayer)pGeoFeatureLayer);
                //save the layer file
                layerFile.Save();

//ask the user whether he'd like to add the layer to the map
                if (DialogResult.Yes == MessageBox.Show("Would you like to add the layer to the map?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    axMapControl1.AddLayerFromFile(saveFileDialog.FileName, 0);
                }
            }

}

private void 单值图ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 
            IMap pMap = axMapControl1.Map;
            ILayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

//获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
             
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);

//定义单值图渲染组件    
            IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass();
            //设置渲染字段对象         
            pUniqueValueRenderer.FieldCount = 1;
            pUniqueValueRenderer.set_Field(0, "ID");            
            //创建填充符号
            ISimpleFillSymbol PFillSymbol = new SimpleFillSymbolClass();
            pUniqueValueRenderer.DefaultSymbol = (ISymbol)PFillSymbol;
            pUniqueValueRenderer.UseDefaultSymbol = false;    
         
           //QI the table from the geoFeatureLayer and get the field number of
            ITable pTable;
            int fieldNumber;
            pTable = pGeoFeatureLayer as ITable ;
            fieldNumber = pTable.FindField("ID");
            if (fieldNumber == -1)
            {
                MessageBox.Show("Can't find field called ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            
            }
             
            //创建并设置随机色谱
            IRandomColorRamp pColorRamp = new RandomColorRampClass();
            pColorRamp.StartHue = 0;
            pColorRamp.MinValue = 99;
            pColorRamp.MinSaturation = 15;
            pColorRamp.EndHue = 360;
            pColorRamp.MaxValue = 100;
            pColorRamp.MaxSaturation = 30;
            pColorRamp.Size = 100;
            //pColorRamp.Size = pUniqueValueRenderer.ValueCount;
            bool k = true;
            pColorRamp.CreateRamp(out ok);
            IEnumColors pEnumRamp;
            pEnumRamp = pColorRamp.Colors;

//为每个值设置一个符号
          int n = pFeatureClass.FeatureCount(null);              
          for (int i = 0; i < n; i++)
          {
              IFeature pFeature = pFeatureCursor.NextFeature();
              IClone pSourceClone = PFillSymbol as IClone;
              ISimpleFillSymbol pSimpleFillSymbol = pSourceClone.Clone() as ISimpleFillSymbol ;
              string pFeatureValue = pFeature.get_Value(pFeature.Fields.FindField("ID")).ToString();
              pUniqueValueRenderer.AddValue(pFeatureValue, "烈度", (ISymbol)pSimpleFillSymbol);
          }
          //为每个符号设置颜色
          for (int i = 0; i <= pUniqueValueRenderer.ValueCount - 1; i++)
          {
              string xv = pUniqueValueRenderer.get_Value(i);
              if (xv != "")
              {
                  ISimpleFillSymbol pNextSymbol = (ISimpleFillSymbol)pUniqueValueRenderer.get_Symbol(xv);
                  pNextSymbol.Color = pEnumRamp.Next();
                  pUniqueValueRenderer.set_Symbol(xv, (ISymbol)pNextSymbol);
       
              }
          }
          //将单值图渲染对象与渲染图层挂钩
          pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer;
          pGeoFeatureLayer.DisplayField = "ID";
          //刷新地图和TOOCotrol
          IActiveView pActiveView = axMapControl1.Map as IActiveView;
          pActiveView.Refresh();
          axTOCControl1.Update();

}
private void 等级图ToolStripMenuItem_Click(object sender, EventArgs e)
        {

//获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 
            IMap pMap = axMapControl1.Map;
            ILayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

//获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature pFeature = pFeatureCursor.NextFeature();
            //////////////////////////////////////////////////////////////////////

//定义所需的接口对象和相关变量

IClassBreaksUIProperties pUIProperties;
            object dataValues;
            object dataFrequency;
            //double[] cb;

int breakIndex;
            long ClassesCount;
            int numClass;
            numClass = 10;
            double[] Classes;
            //////////////////////////////////////////////////////////////////////
            /* We're going to retrieve frequency data from a population 
              field and then classify this data*/

ITable pTable;
            pTable = pFeatureClass as ITable;
            IBasicHistogram pBasicHist = new BasicTableHistogramClass();
            ITableHistogram pTableHist;

pTableHist = (ITableHistogram)pBasicHist;

//Get values and frequencies for the population field into a table histogram object
            pTableHist.Field = "AREA";
            pTableHist.Table = pTable;
            pBasicHist.GetHistogram(out dataValues, out dataFrequency);

IClassifyGEN pClassifyGEN = new QuantileClass();
            pClassifyGEN.Classify(dataValues, dataFrequency, ref numClass);
            Classes = (double[])pClassifyGEN.ClassBreaks;
            ClassesCount = long.Parse(Classes.GetUpperBound(0).ToString());

//Initialise a new class breaks renderer and supply the number of class breaks and the field to perform. the class breaks on.
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();
            pClassBreaksRenderer.Field = "AREA";
            //pClassBreaksRenderer.BreakCount = ClassesCount;
            pClassBreaksRenderer.MinimumBreak = Classes[0];
            pClassBreaksRenderer.SortClassesAscending = true;
            //设置着色对象的分级数目
            pClassBreaksRenderer.BreakCount = int.Parse(ClassesCount.ToString());

//创建并设置随机色谱
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
            pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            IEnumColors pEnumColors;
            IRgbColor pColor1 = new RgbColorClass();
            IRgbColor pColor2 = new RgbColorClass();
            pColor1.Red = 255;
            pColor1.Green = 210;
            pColor1.Blue = 210;
            pColor2.Red = 190;
            pColor2.Green = 0;
            pColor2.Blue = 170;
            pColorRamp.FromColor = pColor1;
            pColorRamp.ToColor = pColor2;
            pColorRamp.Size = numClass;
            bool k = true;
            pColorRamp.CreateRamp(out ok);
            pEnumColors = pColorRamp.Colors;
            pEnumColors.Reset();// use this interface to set dialog properties

pUIProperties = pClassBreaksRenderer as IClassBreaksUIProperties;
            pUIProperties.ColorRamp = "Custom";

ISimpleFillSymbol pSimpleMarkerSymbol = new SimpleFillSymbolClass();

IColor pColor;
            int[] colors = new int[numClass];

// be careful, indices are different for the diff lists    
            for (breakIndex = 0; breakIndex < ClassesCount; breakIndex++)
            {
                
                pClassBreaksRenderer.set_Label (breakIndex,Classes[breakIndex] + " - " + Classes[breakIndex + 1]);
                pUIProperties.set_LowBreak  (breakIndex ,Classes[breakIndex]);
                pSimpleMarkerSymbol = new SimpleFillSymbolClass();
                pColor = pEnumColors.Next();
                pSimpleMarkerSymbol.Color = pColor;
                colors[breakIndex] = pColor.RGB;
               
                pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimpleMarkerSymbol);
                pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);
            }   
           
            //将等级图渲染对象与渲染图层挂钩
            pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
            //刷新地图和TOOCotrol
            IActiveView pActiveView = axMapControl1.Map as IActiveView;
            pActiveView.Refresh();
            axTOCControl1.Update();
        }     
        
        
    private void 柱状图ToolStripMenuItem_Click(object sender, EventArgs e)
        {

//获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 
            IMap pMap = axMapControl1.Map;
            ILayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

//获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
             
            //定义柱状图渲染组建对象
            IChartRenderer pChartRenderer = new ChartRendererClass();
            //定义渲染字段对象并给字段对象实例化为pChartRenderer
            IRendererFields pRendererFields;
            pRendererFields = (IRendererFields)pChartRenderer;
           //向渲染字段对象中添加字段--- 待补充自定义添加
            pRendererFields.AddField("AREA", "AREA");
            pRendererFields.AddField("ID", "ID");

// 通过查找features的所用字段的值,计算出数据字段的最大值,作为设置柱状图的比例大小的依据
            ITable pTable;
            int fieldNumber;
            pTable = pGeoFeatureLayer as ITable;
            // 查找出geoFeatureLayer的属性表中的字段个数
            fieldNumber = pTable.FindField("AREA");
            if (fieldNumber == -1)
            {
                MessageBox.Show("Can't find field called ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
   
            const int  numFields = 2;// 设置bars的个数 
            int[] fieldIndecies = new int[2];
            //long fieldIndex;
            double maxValue;
            bool firstValue;
            //double[] fieldValue=new double[5];
            double  fieldValue;
            fieldIndecies[0] = pTable.FindField("AREA");
            fieldIndecies[1] = pTable.FindField("ID");
            firstValue = true;
            maxValue = 0;          
             int n = pFeatureClass.FeatureCount(null);
             for (int i = 0; i < numFields; i++)
             {
                 IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
                 for (int j = 0; j < n; j++)
                 {
                     IFeature pFeature = pFeatureCursor.NextFeature();
                     fieldValue = Convert.ToDouble(pFeature.get_Value(fieldIndecies[i]));

if (firstValue)
                     {
                         //给maxValue赋初值
                         maxValue = fieldValue;
                         firstValue = false;
                     }
                     else if (fieldValue > maxValue)
                     {
                         maxValue = fieldValue;
                     }

}
             }
                  
            if (maxValue <= 0)
            {
                MessageBox.Show("Failed to calculate the maximum value or maxvalue is 0.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

// 定义并设置渲染时用的chart marker symbol
            IBarChartSymbol pBarChartSymbol = new BarChartSymbolClass();
            pBarChartSymbol.Width = 6;

IChartSymbol pChartSymbol;
            pChartSymbol = pBarChartSymbol as IChartSymbol;

IMarkerSymbol pMarkerSymbol;
            pMarkerSymbol = (IMarkerSymbol)pBarChartSymbol;

IFillSymbol pFillSymbol ;
            //设置pChartSymbol的最大值
            pChartSymbol.MaxValue = maxValue;
            // 设置bars的最大高度 
            pMarkerSymbol.Size = 16;
            //下面给每一个bar设置符号
         
            //定义符号数组
            ISymbolArray  pSymbolArray = (ISymbolArray)pBarChartSymbol;

//克隆pFillSymbol用于符号操作
            //IClone pSourceClone = pFillSymbol as IClone;
            //ISimpleFillSymbol pSimpleFillSymbol = pSourceClone.Clone() as ISimpleFillSymbol;

// 向符号数组中添加设置后的符号
            //pSimpleFillSymbol.Color = GetRGBColor(193, 252, 179);
            //pSymbolArray.AddSymbol(pSimpleFillSymbol as ISymbol);

//pSimpleFillSymbol.Color = GetRGBColor(145, 55, 200);
            //pSymbolArray.AddSymbol(pSimpleFillSymbol as ISymbol);

//添加第一个符号
            pFillSymbol = new SimpleFillSymbolClass();
            pFillSymbol.Color = GetRGBColor(193, 252, 179) as IColor ;
            pSymbolArray.AddSymbol(pFillSymbol as ISymbol) ;
            //添加第二个符号
            pFillSymbol = new SimpleFillSymbolClass();
            pFillSymbol.Color = GetRGBColor(145, 55, 251)as IColor;
            pSymbolArray.AddSymbol(pFillSymbol as ISymbol);

// 设置背景符号 
            //pSimpleFillSymbol.Color = GetRGBColor(239, 150, 190);
            //pChartRenderer.BaseSymbol = pSimpleFillSymbol as ISymbol;

// Disable overpoaster 让符号处于图形中央 
            pChartRenderer.UseOverposter = false;

//pChartRenderer.ChartSymbol = pSymbolArray as IChartSymbol;
            pChartRenderer.ChartSymbol = pChartSymbol as IChartSymbol;
            //pChartRenderer.Label = "AREA";
            pChartRenderer.CreateLegend();

//将柱状图渲染对象与渲染图层挂钩
            pGeoFeatureLayer.Renderer = (IFeatureRenderer)pChartRenderer;
            pGeoFeatureLayer.DisplayField = "ID";
            //刷新地图和TOOCotrol
            IActiveView pActiveView = axMapControl1.Map as IActiveView;
            pActiveView.Refresh();
            axTOCControl1.Update();

}
private void asdToolStripMenuItem_Click(object sender, EventArgs e)
        {

//获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 
            IMap pMap = axMapControl1.Map;
            ILayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

//获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature pFeature = pFeatureCursor.NextFeature();
            //////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////
            IBasicHistogram pHistogram;
            ITableHistogram pTableHistogram = new  BasicTableHistogramClass();
            ITable pTable;
            IClassifyGEN pClassifyGEN = new EqualIntervalClass();
            long ClassesCount;
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();
            IAlgorithmicColorRamp pAlgorithmicColorRamp = new AlgorithmicColorRampClass();
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
            IEnumColors pEnumColors;
            object dataFrequency;
            object dataValue;
            double[] Classes;
            int numClass;
            numClass = 10;

pTable = (ITable)pGeoFeatureLayer;

//根据渲染字段得到渲染信息赋值给两个数组。
            pHistogram = (IBasicHistogram)pTableHistogram;
            pTableHistogram.Field = "AREA";
            pTableHistogram.Table = pTable;
            pHistogram.GetHistogram(out dataValue, out dataFrequency);

//下面是分级方法,用于根据获得的值计算得出符合条件要求的数据

//根据条件计算出Classes和ClassesCount.

pClassifyGEN.Classify(dataValue, dataFrequency, ref numClass);
            //返回一个数组,注意这个数组的下标是从1开始的
            Classes = (double[])pClassifyGEN.ClassBreaks;

ClassesCount = long.Parse(Classes.GetUpperBound(0).ToString());

pClassBreaksRenderer.Field = "AREA";

//创建并设置随机色谱
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
            pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;

IRgbColor pColor1 = new RgbColorClass();
            IRgbColor pColor2 = new RgbColorClass();
            pColor1.Red = 255;
            pColor1.Green = 210;
            pColor1.Blue = 210;
            pColor2.Red = 190;
            pColor2.Green = 0;
            pColor2.Blue = 170;
            pColorRamp.FromColor = pColor1;
            pColorRamp.ToColor = pColor2;
            pColorRamp.Size = 20;
            bool k = true;
            pColorRamp.CreateRamp(out ok);
            pEnumColors = pColorRamp.Colors;
            pEnumColors.Reset();// use this interface to set dialog properties

//设置着色对象的分级数目
            pClassBreaksRenderer.BreakCount = int.Parse(ClassesCount.ToString());
            pClassBreaksRenderer.SortClassesAscending = true;
            //设置颜色条带:

pAlgorithmicColorRamp.FromColor = pColor1;
            pAlgorithmicColorRamp.ToColor = pColor2;
            pAlgorithmicColorRamp.Size = numClass;
            bool re = false;
            pAlgorithmicColorRamp.CreateRamp(out re);
            pEnumColors = pAlgorithmicColorRamp.Colors;
            pEnumColors.Reset();
             //定义图形边界符号
            ILineSymbol pLineSymbol;
        
            IColor pColor;
            int[] colors = new int[numClass];
            int breakIndex = 0;

for (breakIndex = 0; breakIndex < ClassesCount; breakIndex++)
            {
                //pEnumColors.Reset();
                pColor = pEnumColors.Next();
                pSimpleMarkerSymbol.Color = pColor;
                colors[breakIndex] = pColor.RGB;
                pSimpleMarkerSymbol.Style. = esriSimpleMarkerStyle.esriSMSSquare;//.esriSMSCircle;
                pSimpleMarkerSymbol.Size = 10;
                pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimpleMarkerSymbol);
                pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);
                pLineSymbol = new CartographicLineSymbolClass();
                //pSimpleMarkerSymbol.Outline= true ;
               // pEnumColors.Reset();
                //pSimpleMarkerSymbol.OutlineColor = pEnumColors.Next(); ;
            }

ae专题图的更多相关文章

  1. 用ARCGIS配出一张DEM专题图

    专题图是指突出而尽可能完善.详尽地表达制图区内的一种或几种自然或社会经济要素的地图.专题图的制图领域宽广,凡具有空间属性的信息数据都可以用其来表示.由于DEM描述的是地面高程信息,它在测绘.水文.气象 ...

  2. [转] ArcEngine 产生专题图

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

  3. arcgis人口专题图

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  4. [转] AE之分级颜色专题图渲染

    原文 AE之分级颜色专题图渲染 参考代码1 private void 分级渲染ToolStripMenuItem_Click(object sender, EventArgs e) { //值分级 I ...

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

    ArcGIS二次开发是当前gis领域的一项重要必不可少的技能.下面介绍它的基本功能 一.ArcGIS Engine功能 在使用之前首先安装和部署arcgis sdk,(在这里不在赘述相关知识)可以实现 ...

  6. 关于印发利用DEM确定耕地坡度分级技术规定(试行)的通知

    下载:http://files.cnblogs.com/files/gisoracle/%E5%88%A9%E7%94%A8DEM%E7%A1%AE%E5%AE%9A%E8%80%95%E5%9C%B ...

  7. ArcGIS Engine渲染

    符号化之Renderer( 渲染)体系 ArcGIS Engine9.3对GIS数据的符号化分为矢量数据渲染和栅格数据渲染两大类.接下来分别介绍FeatureRender和RasterRender. ...

  8. ArcGIS Earth数据小析

    ArcGIS Earth,一款轻量级的三维地球应用.因为工作关系下载试用了半天,正好借这个机会简单研究一下ArcGIS Earth的大概思路,特别是地形数据的组成和影像数据的加载,在这总结整理一下.下 ...

  9. arcengine 开发经典帖

    http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=25575&page=1&extra= 使用ArcGIS Engine 开发自定义 ...

随机推荐

  1. VS2015调试UWP程序时提示错误DEP0700 : Registration of the app failed. Another user has already installed

    在同一台windows10电脑上调试过一个工程以后,切换了账号再次调试出现错误 DEP0700 : Registration of the app failed. Another user has a ...

  2. Nodejs与ES6系列1:变量声明

    1.声明变量 在JS当中一个变量的作用域(scope)是程序中定义这个变量的区域.变量分为两类,全局(global)的和局部的.其中全局变量的作用域是全局性的,即在JavaScript代码中,它处处都 ...

  3. 涉及 C#的 foreach问题

    当时是用foreach实现遍历,但是函数传入参数是Object类型的,由于Objectl类型没有实现相关接口,所以foreach并不能执行. 那么下面我们来看看,想要使用foreach需要具备什么条件 ...

  4. 检测.net framework 版本

    项目中,自己要制作asp.net项目的安装文件,由于项目依赖于.net framework 3.5 sp1,故需检测环境是否符合要求,才能安装程序 度娘找到检测方案:各.net版本对应的安装补录下都有 ...

  5. Ruby on Rails---Active Admin使用(一)

    概述 Active Admin提供了一个友好的后台管理界面,将CRUD等操作可视化,操作极其方便 安装 1. 添加gem gem "devise", :github => ' ...

  6. Angular21 动态绑定CSS样式

    1 需求 在前端开发中通常需要动态对某些元素的样式进行动态设定,传统的CSS绑定分为CSS类绑定和Style样式绑定:在Angular中利用相关指令同样可以完成CSS类绑定和CSS样式绑定 2 内置指 ...

  7. 【转】干货,Kubernetes中的Source Ip机制。

    准备工作 你必须拥有一个正常工作的 Kubernetes 1.5 集群,用来运行本文中的示例.该示例使用一个简单的 nginx webserver 回送它接收到的请求的 HTTP 头中的源 IP 地址 ...

  8. LeetCode(120):三角形最小路径和

    Medium! 题目描述: 给定一个三角形,找出自顶向下的最小路径和.每一步只能移动到下一行中相邻的结点上. 例如,给定三角形: [ [2], [3,4], [6,5,7], [4,1,8,3] ] ...

  9. Variables and Arithmetic Expression

    Notes from The C Programming Language A decimal point in a constant indicates that it is floating po ...

  10. MySQL命令行的备份与还原

    备份的语法;  mysqldump -uroot -p shop> 数据库路径 还原的语法:  mysql -uroot -p 具体数据库(shop0609)< 数据库路径