Skip to content

Instantly share code, notes, and snippets.

@AlexArcPy
Last active January 31, 2016 08:11
Show Gist options
  • Save AlexArcPy/1a36e15b73b23b723018 to your computer and use it in GitHub Desktop.
Save AlexArcPy/1a36e15b73b23b723018 to your computer and use it in GitHub Desktop.
Sample arcpy helper function
def select_distinct(input_fc,input_field):
'''returns a list of unique values in a field sorted'''
sql = (None, 'GROUP BY {0}'.format(input_field))
cur = arcpy.da.SearchCursor(in_table=input_fc,field_names=["{0}".format(input_field)],
sql_clause=sql)
unique_values = [f[0] for f in cur]
return sorted(unique_values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment