ArcEngine 二次开发中如何使用 IDataStatistics
在AE二次开发过程中,可能需要这样的功能,如统计一个要素类或者属性表中的某一个字段的唯一值,如果这个字段是数字型的,还需要统计字段值的集合,均值,最大值或者最小值等。那么可以通过使用IDataStatistics 实现此类的统计功能。看看怎么实现统计均值:
/// <summary>
/// 获取字段值的平均值,字段必须是数值型的
/// </summary>
/// <param name="pTable">The table.</param>
/// <param name="filedName">Name of the filed.</param>
/// <param name="whereClause">The where clause.</param>
/// <returns></returns>
public static Double GetMean(ITable pTable, String fieldName, String whereClause)
{
try
{
IDataStatistics pDataStatistics = new DataStatisticsClass();
pDataStatistics.Cursor = pTable.Search(CreateQueryFilter(whereClause), false);
pDataStatistics.Field = fieldName;
IStatisticsResults results = pDataStatistics.Statistics;
return results.Mean;
}
catch (Exception ex)
{
throw ex;
}
}

浙公网安备 33010602011771号