<?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 Re: How to identify unique values in selected set in geoprocessor (Python) in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481923#M16173</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;if you have a list, then use set&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; stuff = [1,1,1,1,1,2,2,2,3,4,4,4,4,4,5,5,5,5,1,1,1,1,1]&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; stuff_set = set(stuff)&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; print stuff_set&lt;BR /&gt;set([1, 2, 3, 4, 5])&lt;BR /&gt;&lt;BR /&gt;then count the set, if you then need code for frequencies, steal defs out of&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=BDF21676-1422-2418-34E6-A29C6BAC8A0B"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=BDF21676-1422-2418-34E6-A29C6BAC8A0B&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you Dan. That helps, and I can see many, many uses for the Descriptive Statistics (not to mention some past efforts where I poorly kludged something together that your script would have solved much more elegantly)!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the thing I am missing is how to create the list; how do I dump a list of the values in a field in selected set of attributes to a list? Is MakeTableView the best way to do that? This would be iterative, as I'd do it within a while loop. Then I can run your descriptive statistics tool on that. Is that the fastest way? Thanks again for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Aug 2010 15:20:20 GMT</pubDate>
    <dc:creator>AlisaWade</dc:creator>
    <dc:date>2010-08-19T15:20:20Z</dc:date>
    <item>
      <title>How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481921#M16171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings -&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my script, I select out points based on the value in one field. I want to then calculate the number of unique values in another field within that selected set. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I select the set:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.SelectLayerByAttribute("TempData", "NEW_SELECTION", sBlockField + " &amp;gt;= 90")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I can easily access the number of selected records:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.GetCount("TempData").GetOutput(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But how do I get the unique values in "Field2" of the selected set?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I searched these and older forums; I don't see anything along these lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Aug 2010 18:09:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481921#M16171</guid>
      <dc:creator>AlisaWade</dc:creator>
      <dc:date>2010-08-18T18:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481922#M16172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;if you have a list, then use set&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; stuff = [1,1,1,1,1,2,2,2,3,4,4,4,4,4,5,5,5,5,1,1,1,1,1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; stuff_set = set(stuff)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print stuff_set&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set([1, 2, 3, 4, 5])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;then count the set, if you then need code for frequencies, steal defs out of&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=BDF21676-1422-2418-34E6-A29C6BAC8A0B"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=BDF21676-1422-2418-34E6-A29C6BAC8A0B&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Aug 2010 18:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481922#M16172</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-08-18T18:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481923#M16173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;if you have a list, then use set&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; stuff = [1,1,1,1,1,2,2,2,3,4,4,4,4,4,5,5,5,5,1,1,1,1,1]&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; stuff_set = set(stuff)&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; print stuff_set&lt;BR /&gt;set([1, 2, 3, 4, 5])&lt;BR /&gt;&lt;BR /&gt;then count the set, if you then need code for frequencies, steal defs out of&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=BDF21676-1422-2418-34E6-A29C6BAC8A0B"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=BDF21676-1422-2418-34E6-A29C6BAC8A0B&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you Dan. That helps, and I can see many, many uses for the Descriptive Statistics (not to mention some past efforts where I poorly kludged something together that your script would have solved much more elegantly)!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the thing I am missing is how to create the list; how do I dump a list of the values in a field in selected set of attributes to a list? Is MakeTableView the best way to do that? This would be iterative, as I'd do it within a while loop. Then I can run your descriptive statistics tool on that. Is that the fastest way? Thanks again for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Aug 2010 15:20:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481923#M16173</guid>
      <dc:creator>AlisaWade</dc:creator>
      <dc:date>2010-08-19T15:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481924#M16174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dan's tool contains the search cursors in the classes of the tool so you dont need to make a list of the field contents to use it. If you wanted to code out the stats yourself instead of using the tool you would make a list and do yourlist.append(row.getvalue("field")) in the while loop for the cursor. If you only need the stats provided by Dan's tool though I would use that as it will save you some lines in your script and make it cleaner looking. Kudos to you by the way Dan, that tool is a great solution to not having field stats in python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Aug 2010 17:09:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481924#M16174</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-08-19T17:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481925#M16175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;List comprehensions are an ideal way to get a list of field values:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myList = [f.getValue(someField) for f in arcpy.SearchCursor(someFC)]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SearchCursor arguments can include a SQL query, or can access a feature layer and therefore its selection set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 22:49:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481925#M16175</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2010-08-20T22:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481926#M16176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bruce, interesting point, however, I will have to recheck my benchmarking since the repetitive calls to the searchcursor seemed to be worse than my approach (ie ...SearchCursor(someFC)] ), I will recheck in arcpy to see if there is a speed difference...in the interim, other may steal my code as they see fit.&amp;nbsp; If you have any benchmarking/timing information I would appreciate an update&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 23:16:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481926#M16176</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-08-20T23:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481927#M16177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I didn't do a timing test, but I did use the repetitive calls to an update cursor; I put another where clause in front of each call to the update cursor so that I limited where it looked based on another field that I changed. The speed was ok (certainly not fast, but not painfully slow either). Thanks to everyone for the help; very appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 14:11:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481927#M16177</guid>
      <dc:creator>AlisaWade</dc:creator>
      <dc:date>2010-08-30T14:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481928#M16178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use the Summary Statistics tool.&amp;nbsp; Assuming that "Field2" is your field, add Field2 as your statistics field and get the COUNT statistic.&amp;nbsp; For the Case Field, input Field2 as well.&amp;nbsp; You'll get an output table that has each unique value of Field2 as well as the number of times that value appears.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I should add that you should write the output of Summary Statistics to in_memory.&amp;nbsp; See &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Using_in_memory_workspace/002w0000005s000000/"&gt;Using in_memory workspace&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; You can write to in_memory in Python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 22:02:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481928#M16178</guid>
      <dc:creator>DaleHoneycutt</dc:creator>
      <dc:date>2010-08-30T22:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify unique values in selected set in geoprocessor (Python)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481929#M16179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Bruce, interesting point, however, I will have to recheck my benchmarking since the repetitive calls to the searchcursor seemed to be worse than my approach (ie ...SearchCursor(someFC)] ), I will recheck in arcpy to see if there is a speed difference...in the interim, other may steal my code as they see fit.&amp;nbsp; If you have any benchmarking/timing information I would appreciate an update&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good news, at 10.1 we are told to expect much faster performance from cursors.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jun 2011 21:39:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-identify-unique-values-in-selected-set-in/m-p/481929#M16179</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2011-06-28T21:39:25Z</dc:date>
    </item>
  </channel>
</rss>

