关键之处在于获取每个点所代表的的值 这里使用geodatabase类库中idatastatistic接口进行统计字段,再将结果传递给esrisysytem.istatisticsResult进行.
需用到引用
1 using ESRI.ArcGIS.Display; 2 using ESRI.ArcGIS.Carto; 3 using ESRI.ArcGIS.esriSystem; 4 using ESRI.ArcGIS.Geodatabase;
代码
class="code_img_closed" src="/Upload/Images/2013122012/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('5a4f26cc-18c2-4b14-8036-ab2c4525bc7f',event)" src="/Upload/Images/2013122012/2B1B950FA3DF188F.gif" alt="" />1 private void dotToolStripMenuItem_Click(object sender, EventArgs e) 2 { 3 IGeoFeatureLayer pLayer = this.axMapControl1.get_Layer(0)as IGeoFeatureLayer; 4 ITable pTable = pLayer.FeatureClass as ITable; 5 IQueryFilter pQueryFilter=new QueryFilterClass(); 6 pQueryFilter.AddField("PERIMETER"); 7 ICursor pCursor = pTable.Search(pQueryFilter, true); 8 IDataStatistics pDataStatistics = new DataStatisticsClass(); 9 pDataStatistics.Cursor = pCursor;//数据来源 10 pDataStatistics.Field = "PERIMETER"; 11 IStatisticsResults pStatisticsResult = pDataStatistics.Statistics; 12 double Dvalues = (pStatisticsResult.Minimum+pStatisticsResult.Maximum)/10;//根据情况而定 13 14 IDotDensityRenderer pDotDensityRenderer=new DotDensityRendererClass(); 15 16 IRendererFields pRendererField = pDotDensityRenderer as IRendererFields; 17 pRendererField.AddField("PERIMETER", "PERIMETER"); 18 19 IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass(); 20 pDotDensityFillSymbol.DotSize =1; 21 pDotDensityFillSymbol.BackgroundColor = GetRgbColor(100, 100, 100); 22 pDotDensityFillSymbol.Color = GetRgbColor(255, 200, 0); 23 24 ISymbolArray pSymbolArray = pDotDensityFillSymbol as ISymbolArray; 25 ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); 26 pMarkerSymbol.Color = GetRgbColor(255, 0, 0); 27 pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; 28 pMarkerSymbol.Size = 10; 29 pSymbolArray.AddSymbol(pMarkerSymbol as ISymbol); 30 31 pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol; 32 pDotDensityRenderer.DotValue = Dvalues; 33 pDotDensityRenderer.CreateLegend(); 34 35 pLayer.Renderer = pDotDensityRenderer as IFeatureRenderer; 36 this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); 37 this.axTOCControl1.Update(); 38 39 40 41 }View Code