Last active
August 29, 2015 13:55
-
-
Save knu2xs/8721712 to your computer and use it in GitHub Desktop.
This is a Python function returning unique values from a field in an ArcGIS table, either a stand alone table or a feature class. It was adapted from code sample on ArcGIS resource center Help documentation on arcpy.da.SearchCursor http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Depends on first importing arcpy.da at top of script | |
def unique_values(input_table, field): | |
# search cursor wrapped in list generator creating list of all values | |
values = (row[0] for row in arcpy.da.SearchCursor(input_table, (field))) | |
# pass list into set to get only unique values and return the result | |
return sorted(set(values)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment