Skip to content

Instantly share code, notes, and snippets.

@tyler-austin
Created May 30, 2017 21:12
Show Gist options
  • Save tyler-austin/5c3318598c658d74cdb6a7938e9d4a10 to your computer and use it in GitHub Desktop.
Save tyler-austin/5c3318598c658d74cdb6a7938e9d4a10 to your computer and use it in GitHub Desktop.
arcpy unique field values
import arcpy
import os
def unique_values(vector_data, field):
with arcpy.da.SearchCursor(vector_data, [field]) as cursor:
return sorted({row[0] for row in cursor})
vector_data = os.path.join(r"/path/to/feature/class")
field = 'special_field'
unique_vals = unique_values(vector_data, field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment