Created
May 30, 2017 21:12
-
-
Save tyler-austin/5c3318598c658d74cdb6a7938e9d4a10 to your computer and use it in GitHub Desktop.
arcpy unique field values
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
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