Select to view content in your preferred language

Unique attribute values

554
2
08-26-2011 01:09 AM
ManojrajTeli
Deactivated User
Is it possible to get unique values for attributes of the feature.Thank you in advance
0 Kudos
2 Replies
TerryGiles
Frequent Contributor
Do you need the unique values for just one feature or from a given attribute in several features?

If you just want the unique values across all attributes in one feature you could do something like this -

                    List<string> values = new List<string>();
                    foreach (var item in feature.Attributes)
                    {
                        if (!values.Contains(item.Value.ToString()))
                        {
                            values.Add(item.Value.ToString());
                        }
                    }



If you need to get the unique values from a series of features see this forum thread -

http://forums.arcgis.com/threads/36312-Attribute-Query-Distinct-values?p=127568#post127568.  It's not fast if you have a large number of features to handle but it works. 

Terry
0 Kudos
JenniferNery
Esri Regular Contributor
You may also use Distinct() in System.Linq as in Post# 10 of this thread: http://forums.arcgis.com/threads/16305-Attribute-Query-Task-Question
0 Kudos