Arcengine获取图层某个字段唯一值的方法

private ArrayList GetLayerUniqueFieldValueByDataStatistics(IFeatureLayer 

pFeatureLayer, string fieldName)
        {
            ArrayList arrValues = new ArrayList();
            IQueryFilter pQueryFilter = new QueryFilterClass();
            IFeatureCursor pFeatureCursor = null;

            pQueryFilter.SubFields = fieldName;
            pFeatureCursor = pFeatureLayer.FeatureClass.Search(pQueryFilter, true);

            IDataStatistics pDataStati = new DataStatisticsClass();
            pDataStati.Field = fieldName;
            pDataStati.Cursor = (ICursor)pFeatureCursor;

            IEnumerator pEnumerator = pDataStati.UniqueValues;
            pEnumerator.Reset();
            while (pEnumerator.MoveNext())
            {
                object pObj = pEnumerator.Current;
                arrValues.Add(pObj.ToString());
            }

            arrValues.Sort();
            return arrValues;
        }

转载自:https://blog.csdn.net/l974199574/article/details/47724177

You may also like...