<?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: Area of a raster in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660184#M51299</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's no simple property of COUNT for raster values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It can be read from raster attribute table with a search cursor in this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy,&amp;nbsp; inRaster = r"C:\test.gdb\myRaster"&amp;nbsp; # Build attribute table if needed #arcpy.BuildRasterAttributeTable_management(inRaster, "OVERWRITE")&amp;nbsp; # Create a search cursor for desired raster VALUE sCur = arcpy.SearchCursor(inRaster, '"VALUE" = 1') for row in sCur: &amp;nbsp;&amp;nbsp;&amp;nbsp; cellCount = row.getValue("COUNT") &amp;nbsp;&amp;nbsp;&amp;nbsp; print cellCount&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Nov 2012 05:32:50 GMT</pubDate>
    <dc:creator>MarcinGasior</dc:creator>
    <dc:date>2012-11-09T05:32:50Z</dc:date>
    <item>
      <title>Area of a raster in Python</title>
      <link>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660183#M51298</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;BR /&gt;&lt;SPAN&gt;I have a file full of rasters with a Value of 1, the rest is NoData. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to extract the Count for each raster, to then calculate the area, by multiplying by the cellsize. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was trying to do this with the Get Raster Properties tool, using UNIQUEVALUECOUNT as the property type yin the script but instead of returning the count, it would return a 1. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; count = arcpy.GetRasterProperties_management (fileName, "VALUETYPE")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there an automated way to extract the count from a raster, using Python????&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would really appreciate your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 01:01:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660183#M51298</guid>
      <dc:creator>NataliaOcampo</dc:creator>
      <dc:date>2012-11-09T01:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Area of a raster in Python</title>
      <link>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660184#M51299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's no simple property of COUNT for raster values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It can be read from raster attribute table with a search cursor in this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy,&amp;nbsp; inRaster = r"C:\test.gdb\myRaster"&amp;nbsp; # Build attribute table if needed #arcpy.BuildRasterAttributeTable_management(inRaster, "OVERWRITE")&amp;nbsp; # Create a search cursor for desired raster VALUE sCur = arcpy.SearchCursor(inRaster, '"VALUE" = 1') for row in sCur: &amp;nbsp;&amp;nbsp;&amp;nbsp; cellCount = row.getValue("COUNT") &amp;nbsp;&amp;nbsp;&amp;nbsp; print cellCount&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 05:32:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660184#M51299</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-11-09T05:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Area of a raster in Python</title>
      <link>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660185#M51300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you so much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This was very helpful!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 12:56:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/area-of-a-raster-in-python/m-p/660185#M51300</guid>
      <dc:creator>NataliaOcampo</dc:creator>
      <dc:date>2012-11-09T12:56:33Z</dc:date>
    </item>
  </channel>
</rss>

