<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to iterate through unique values in a field name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-iterate-through-unique-values-in-a-field/m-p/594688#M46563</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Essentially what I envision the process to look like is to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. iterate or loop through all the unique values in the NAME field within my FireBoundaries FC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. do a select by location for each unique value: Grid Pages that intersect with the selected FireBoundary.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Export the selected pages to pdfs in a folder that is the same name as the FireBoundary.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So in the end I would have a folder for each district.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any pointers or tips would be appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Nov 2013 18:48:18 GMT</pubDate>
    <dc:creator>CraigMcDade</dc:creator>
    <dc:date>2013-11-13T18:48:18Z</dc:date>
    <item>
      <title>How to iterate through unique values in a field name</title>
      <link>https://community.esri.com/t5/python-questions/how-to-iterate-through-unique-values-in-a-field/m-p/594688#M46563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Essentially what I envision the process to look like is to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. iterate or loop through all the unique values in the NAME field within my FireBoundaries FC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. do a select by location for each unique value: Grid Pages that intersect with the selected FireBoundary.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Export the selected pages to pdfs in a folder that is the same name as the FireBoundary.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So in the end I would have a folder for each district.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any pointers or tips would be appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 18:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-iterate-through-unique-values-in-a-field/m-p/594688#M46563</guid>
      <dc:creator>CraigMcDade</dc:creator>
      <dc:date>2013-11-13T18:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to iterate through unique values in a field name</title>
      <link>https://community.esri.com/t5/python-questions/how-to-iterate-through-unique-values-in-a-field/m-p/594689#M46564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 19:41:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-iterate-through-unique-values-in-a-field/m-p/594689#M46564</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-11-13T19:41:27Z</dc:date>
    </item>
  </channel>
</rss>

