统计是地理信息系统基本功能之一,统计即为对某一图层的属性表的某一字段进行统计,得到其数目、最大值、最小值、众数等统计信息。
统计需要两个必要信息:要素、字段。
ArcGIS Engine中统计使用DataStatics类、IDataStatics接口
ILayer pLayer = getLayerByName(comboBox1.Text);
IFeatureLayer pFeaLyr=pLayer as IFeatureLayer;
if(pFeaLyr==null) return;
IFeatureCursor pCursor = pFeaLyr.Search(null,true);
IDataStatistics pStatic = new DataStatisticsClass();
pStatic.Field = comboBox2.Text;
pStatic.Cursor = pCursor as ICursor;
MessageBox.Show(""+pStatic.Statistics.Count);