关键之处在于获取每个点所代表的的值 这里使用geodatabase类库中idatastatistic接口进行统计字段,再将结果传递给esrisysytem.istatisticsResult进行.
需用到引用
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
代码
private void dotToolStripMenuItem_Click(object sender, EventArgs e)
{
IGeoFeatureLayer pLayer = this.axMapControl1.get_Layer()as IGeoFeatureLayer;
ITable pTable = pLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter=new QueryFilterClass();
pQueryFilter.AddField("PERIMETER");
ICursor pCursor = pTable.Search(pQueryFilter, true);
IDataStatistics pDataStatistics = new DataStatisticsClass();
pDataStatistics.Cursor = pCursor;//数据来源
pDataStatistics.Field = "PERIMETER";
IStatisticsResults pStatisticsResult = pDataStatistics.Statistics;
double Dvalues = (pStatisticsResult.Minimum+pStatisticsResult.Maximum)/;//根据情况而定 IDotDensityRenderer pDotDensityRenderer=new DotDensityRendererClass(); IRendererFields pRendererField = pDotDensityRenderer as IRendererFields;
pRendererField.AddField("PERIMETER", "PERIMETER"); IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass();
pDotDensityFillSymbol.DotSize =;
pDotDensityFillSymbol.BackgroundColor = GetRgbColor(, , );
pDotDensityFillSymbol.Color = GetRgbColor(, , ); ISymbolArray pSymbolArray = pDotDensityFillSymbol as ISymbolArray;
ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
pMarkerSymbol.Color = GetRgbColor(, , );
pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
pMarkerSymbol.Size = ;
pSymbolArray.AddSymbol(pMarkerSymbol as ISymbol); pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol;
pDotDensityRenderer.DotValue = Dvalues;
pDotDensityRenderer.CreateLegend(); pLayer.Renderer = pDotDensityRenderer as IFeatureRenderer;
this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
this.axTOCControl1.Update(); }