<?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 Select X number of maximum value grid cells in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204292#M2881</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a raster (grid) file that has about ~11,000 columns and ~ 6,000 rows.&amp;nbsp; I want to select / create a new grid that contains the top 10,000 valued cells.&amp;nbsp; I have done two analyses and want to compare the 'spatial overlap' between the two approaches for the top 10,000 cells.&amp;nbsp; I have yet to arrive at any method, let alone a clever one, to perform this operation.&amp;nbsp; Does anyone have a suggestion on how to perform such a task?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you kindly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 26 May 2012 18:11:14 GMT</pubDate>
    <dc:creator>MichaelJust</dc:creator>
    <dc:date>2012-05-26T18:11:14Z</dc:date>
    <item>
      <title>Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204292#M2881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a raster (grid) file that has about ~11,000 columns and ~ 6,000 rows.&amp;nbsp; I want to select / create a new grid that contains the top 10,000 valued cells.&amp;nbsp; I have done two analyses and want to compare the 'spatial overlap' between the two approaches for the top 10,000 cells.&amp;nbsp; I have yet to arrive at any method, let alone a clever one, to perform this operation.&amp;nbsp; Does anyone have a suggestion on how to perform such a task?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you kindly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 May 2012 18:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204292#M2881</guid>
      <dc:creator>MichaelJust</dc:creator>
      <dc:date>2012-05-26T18:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204293#M2882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could try transforming the raster into an array using arcpy.RasterToNumPyArray.&amp;nbsp; From there is just sorting the array and read the value contained in the position (9,999). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When you know this value you can use raster calculator in order to generate a new raster with the top 10,000 values of your raster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope it helps&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 12:00:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204293#M2882</guid>
      <dc:creator>SebastianSantibanez</dc:creator>
      <dc:date>2012-05-30T12:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204294#M2883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you this should work.&amp;nbsp; However, the size of the raster exceeds Excel's (where I 'read' the array data right?) current row limits.&amp;nbsp; So I think I'll need to raster to points in Arc and then use the SORT command in Arc and then do the Raster Calculator operations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 19:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204294#M2883</guid>
      <dc:creator>MichaelJust</dc:creator>
      <dc:date>2012-05-30T19:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204295#M2884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could also try the following;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- open the Reclassify GP tool dialog and select your input raster&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- hit the Classify... button (to the right of new values)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- on the Classification dialog, hit the % button (far left of Break Values)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- now you can drag the blue vertical lines to choose your top % (i.e. 10000 is what % of number of cells in your raster?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- hit OK, and OK agian to do the Reclassify&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now you have a integer raster and you know what value represents the top 10000 values&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- use the Con tool &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; - Input conditional raster = integer raster you created above&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; - Expression, hit the SQL button and create the "where clause", viz., "Value" = the value that represents the top 10000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; - Input true raster = your initial input raster&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; - Hit OK&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 15:14:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204295#M2884</guid>
      <dc:creator>SteveLynch</dc:creator>
      <dc:date>2012-05-31T15:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204296#M2885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;I have a raster (grid) file that has about ~11,000 columns and ~ 6,000 rows.&amp;nbsp; I want to select / create a new grid that contains the top 10,000 valued cells.&amp;nbsp; I have done two analyses and want to compare the 'spatial overlap' between the two approaches for the top 10,000 cells.&amp;nbsp; I have yet to arrive at any method, let alone a clever one, to perform this operation.&amp;nbsp; Does anyone have a suggestion on how to perform such a task?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach that may be more automated that Steve's approach is the Slice() tool. Seems to me a better approach (for most modeling exercises) would be to locate the top 10 percent, rather than the top 1000, ie, where are the "hot areas", in a scale-independent manner:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;topcells = SetNull(Slice(ingrid,100,"EQUALAREA") &amp;lt; 90,ingrid)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you wanted to set this as a number of cells, you'd need an extra step to count the cells and pick a threshhold:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;datacells = SetNull(IsNull(ingrid),1)
... arcpy.analysis.Statistics(datacells,"in_memory/tmpStat","COUNT SUM")
... Rows = arcpy.SearchCursor("in_memory/tmpStat")
... cellCount = Rows.next().SUM_COUNT
... arcpy.Delete_management("in_memory/tmpStat")
... # find percent cutoff for ~ 10,000 cells (if there are ties this will not be precise)
... # levels should be adjusted to match the magnitude of your percent 
... #&amp;nbsp;&amp;nbsp; (this could be automated using math.log to measure the size 
... #&amp;nbsp;&amp;nbsp; of your percent value, I leave that to someone else)
... lev = 100
... thresh = lev * ( 1.0 - (10000 / cellCount))
... topcells = SetNull(Slice(ingrid,lev,"EQUAL_AREA") &amp;lt; thresh,ingrid)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:08:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204296#M2885</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204297#M2886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;I have a raster (grid) file that has about ~11,000 columns and ~ 6,000 rows.&amp;nbsp; I want to select / create a new grid that contains the top 10,000 valued cells.&amp;nbsp; I have done two analyses and want to compare the 'spatial overlap' between the two approaches for the top 10,000 cells.&amp;nbsp; I have yet to arrive at any method, let alone a clever one, to perform this operation.&amp;nbsp; Does anyone have a suggestion on how to perform such a task?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach that may be more automated that Steve's approach is the Slice() tool. Seems to me that a more useful approach (for most modeling exercises) may be to locate the top 10 percent of cells, rather than the top 10,000, ie, where are the "hot areas", in a scale-independent manner:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from arcpy.sa import *
topcells10&amp;nbsp; = SetNull(Slice(ingrid,10,"EQUAL_AREA") &amp;lt;= 9,ingrid) # top 10% cell values
topcells10x = SetNull(Slice(ingrid,10,"EQUAL_AREA") &amp;lt;= 9,1) # top 10% cells tagged "1"
topcells01&amp;nbsp; = SetNull(Slice(ingrid,100,"EQUAL_AREA") &amp;lt;= 99,ingrid) # top 1%
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you decide to stick with your original approach of number of cells, you'd need an extra step to count the cells and estimate a percentage from that number:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
datacells = SetNull(IsNull(ingrid),1)
tmpStat = "in_memory/tmpStat"
arcpy.analysis.Statistics(datacells,tmpStat,"COUNT SUM")
Rows = arcpy.SearchCursor(tmpStat)
cellCount = Rows.next().SUM_COUNT
arcpy.Delete_management(tmpStat)
# find percent cutoff for ~ 10,000 cells (if there are ties this will not be precise)
# "lev" value may be adjusted to match the magnitude of your percent and how
# close you want to hit your number of cells
#&amp;nbsp;&amp;nbsp; (this could be automated using math.log10 to measure the size 
#&amp;nbsp;&amp;nbsp; of your percent value; I leave that to someone else)
lev = 100
thresh = lev * ( 1.0 - (10000 / cellCount))
topcells = SetNull(Slice(ingrid,lev,"EQUAL_AREA") &amp;lt;= thresh,ingrid)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:08:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204297#M2886</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select X number of maximum value grid cells</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204298#M2887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve and Curt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the suggestions.&amp;nbsp; These methods add some elegance to the procedure.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2012 01:50:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/select-x-number-of-maximum-value-grid-cells/m-p/204298#M2887</guid>
      <dc:creator>MichaelJust</dc:creator>
      <dc:date>2012-06-04T01:50:38Z</dc:date>
    </item>
  </channel>
</rss>

