How to iterate through unique values in a field name

2703
1
11-13-2013 10:48 AM
CraigMcDade
Occasional Contributor III
I have a street atlas of our county in data driven pages (632 pages). I want to divide these up into mini atlases based on the fire district, so that I can give each fire department a mapbook of only the pages in their district.

Essentially what I envision the process to look like is to:

1. iterate or loop through all the unique values in the NAME field within my FireBoundaries FC.
2. do a select by location for each unique value: Grid Pages that intersect with the selected FireBoundary.
3. Export the selected pages to pdfs in a folder that is the same name as the FireBoundary.

So in the end I would have a folder for each district.

I started this process in model builder and then realized it is not quite possible, so I'm trying to switch to python to automate. In my head it seems really simple but I'm just not getting anywhere. So far I have created a unique list of values, but I'm not sure if that is the starting point or if my process is correct:

import arcpy

FireBoundary = r"Path/to/my/sdeconnection"
field = "NAME"

# Use SearchCursor with list comprehension to return a unique set of values in the specified field
values = [row[0] for row in arcpy.da.SearchCursor(FireBoundary, (field))]
uniqueValues = set(values)
print(uniqueValues)


Any pointers or tips would be appreciated.
Tags (2)
0 Kudos
1 Reply
MathewCoyle
Frequent Contributor
Definitely a good first step. Next you'll want to iterate over each unique value in your list and create a feature layer with the value defined as the where clause to create a layer of just that value. Do a select by location to get all the ddp rows you need then export those.

Alternatively you can run an intersect on your ddp layer and your fire areas to get a match of ddp rows and fire areas to export.
0 Kudos