Created
December 18, 2018 14:33
-
-
Save maptastik/13f361d4cfa3d90586af56b610675fdd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
""" Generate a list of unique values for a field in a feature class | |
Parameters: | |
fc (str): Input feature class | |
field (str): Field to find unique values for | |
Returns: | |
list: unique values in a field | |
""" | |
def uniqueVals(fc, field): | |
valsList = [] | |
with arcpy.da.SearchCursor(fc, field) as cursor: | |
for row in cursor: | |
if row[0] not in valsList: | |
valsList.append(row[0]) | |
if None in valsList: | |
valsList.remove(None) | |
valsList.sort() | |
return valsList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment