<?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 categorize a raster based on pixel count within a moving kernel? in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683110#M9978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;I thought of doing this as well. But there may be a problem. I think cells closer to the edge of the raster may be summed based on fewer cells than cells in the middle. The sample image in the ArcGIS Desktop help indicates that this may be the case (see image below). For example, notice the '11' at the upper left of the Output Raster. That's summed using only four cells (since it is at the edge of the raster). Compare this to the '24' that is outlined in yellow in the Output Raster. This is summed using nine cells. I am using a circular analysis shape as well. I'm interested to hear what you think. I sure could be wrong on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/490019_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 25 Apr 2020 13:11:05 GMT</pubDate>
    <dc:creator>MichaelLohr</dc:creator>
    <dc:date>2020-04-25T13:11:05Z</dc:date>
    <item>
      <title>How to categorize a raster based on pixel count within a moving kernel?</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683108#M9976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a classified raster with four land cover classes - built-up, vegetation, water and barren land.&lt;/P&gt;&lt;P&gt;Now, I &lt;STRONG&gt;want to categorize the built-up areas into three more classes&lt;/STRONG&gt; - high built-up density, medium built-density and low built-up density.&lt;/P&gt;&lt;P&gt;I have &lt;STRONG&gt;reclassified my raster into two classes - built-up is 1&lt;/STRONG&gt; and vegetation, water and barren land has been merged into a single class &lt;STRONG&gt;0&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;For categorizing the built-up I am considering a &lt;STRONG&gt;moving circular neighborhood with a radius of&amp;nbsp;150&amp;nbsp;meters&lt;/STRONG&gt;. My raster has a &lt;STRONG&gt;spatial resolution of 30 meters&lt;/STRONG&gt;. As the kernel (neighborhood) moves, the central pixel is assigned a category every time.&lt;/P&gt;&lt;P&gt;And, the &lt;STRONG&gt;conditions for categorization&lt;/STRONG&gt; are: &lt;STRONG&gt;high density&lt;/STRONG&gt; if more than &lt;STRONG&gt;50% of pixels&lt;/STRONG&gt; within the neighborhood are built-up (class value = 2), &lt;STRONG&gt;medium density&lt;/STRONG&gt; if &lt;STRONG&gt;25 - 50%&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;of pixels&lt;/STRONG&gt; within the neighborhood are built-up (class value = 3) and &lt;STRONG&gt;low density&lt;/STRONG&gt; if &lt;STRONG&gt;less than 25% pixels&lt;/STRONG&gt;&amp;nbsp;within the neighborhood are built-up (class value = 4).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have been trying to use the model builder and the CON expression from the raster calculator. But have failed to get the desired output.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help if anybody has any idea as to how can this problem be solved!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Feb 2018 09:38:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683108#M9976</guid>
      <dc:creator>NilakshiChatterji1</dc:creator>
      <dc:date>2018-02-23T09:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize a raster based on pixel count within a moving kernel?</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683109#M9977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/focal-statistics.htm"&gt;&lt;STRONG&gt;Focal Statistics&lt;/STRONG&gt; &lt;/A&gt;....&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you have 0 and 1 in your raster I would suggest using a&lt;STRONG&gt; focal sum&lt;/STRONG&gt; since nothing is going to return percentage.&lt;/P&gt;&lt;P&gt;You will just need to know how many cells constitute your 150 m circular neighborhood with your 30m cell size.&lt;/P&gt;&lt;P&gt;Do a count.&amp;nbsp; 150 at 30 for a rectangular neighborhood would be 5x5 = 25 cells... a circle will have slightly less.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;sum is 13 or greater, then you have &amp;gt;50% so class 2 (ie 12.5/25)&lt;/LI&gt;&lt;LI&gt;sum is 6 -12 , then you have 25-50% so class 3&lt;/LI&gt;&lt;LI&gt;sum &amp;lt; 6&amp;nbsp; then class 4.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So get the sums from your binary raster (0's and 1's)&lt;/P&gt;&lt;P&gt;Reclass the sums raster, leaving 0 as 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No need for Con&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Feb 2018 10:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683109#M9977</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-02-23T10:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize a raster based on pixel count within a moving kernel?</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683110#M9978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;I thought of doing this as well. But there may be a problem. I think cells closer to the edge of the raster may be summed based on fewer cells than cells in the middle. The sample image in the ArcGIS Desktop help indicates that this may be the case (see image below). For example, notice the '11' at the upper left of the Output Raster. That's summed using only four cells (since it is at the edge of the raster). Compare this to the '24' that is outlined in yellow in the Output Raster. This is summed using nine cells. I am using a circular analysis shape as well. I'm interested to hear what you think. I sure could be wrong on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/490019_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Apr 2020 13:11:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683110#M9978</guid>
      <dc:creator>MichaelLohr</dc:creator>
      <dc:date>2020-04-25T13:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize a raster based on pixel count within a moving kernel?</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683111#M9979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;edges are treated differently since they can't had a 9 cell window.&amp;nbsp; Which is why it is important to use an extent larger than you critically need and the data are available&lt;/P&gt;&lt;P&gt;The edge treatment is correct given the window limitations along the edges and the corners.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Apr 2020 19:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683111#M9979</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-04-25T19:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize a raster based on pixel count within a moving kernel?</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683112#M9980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; I would suggest using a focal sum since nothing is going to return percentage&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a neat trick for this. FocalStatistics with MEAN on a Boolean (0-1) raster, with the results then multiplied&amp;nbsp;by 100, gives you percentage in the window. This will also handle the edges better (although of course the number of cells is less so you could see some artifacts as some cells in your neighborhood are NoData when you get to the edge. (If you want to suppress those partial values from being calculated you can use the DATA|NODATA flag in Focal Statistics, then the edge neighborhood cells will be set to NoData.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do this inside Raster Calculator:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="number token"&gt;100&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; FocalStatistics&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"inraster"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; NbrCircle&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;150&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MAP"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MEAN"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; the conditions for categorization are: high density if more than 50% of pixels within the neighborhood are built-up (class value = 2), medium density if 25 - 50% of pixels within the neighborhood are built-up (class value = 3) and low density if less than 25% pixels within the neighborhood are built-up (class value = 4).&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use Reclassify, or my favorite, Con:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"pct"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;50&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"pct"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;25&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you want to reclassify 0 to 0 as Dan suggests, add one more:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"pct"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;50&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"pct"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;25&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"pct"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Apr 2020 21:49:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/how-to-categorize-a-raster-based-on-pixel-count/m-p/683112#M9980</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2020-04-25T21:49:12Z</dc:date>
    </item>
  </channel>
</rss>

