<?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 Get Cell Size from Raster Parameter? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196270#M15034</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to set up a script that takes a raster parameter and a polygon parameter, converts the polygon to raster, and uses the two rasters in the zonal statistics tool.&amp;nbsp; I would like the cell size of the new raster (converted from polygon) to be the same as that of the raster parameter. The describe function does not expose cell size for rasters, and I have no other ideas.&amp;nbsp; Thanks for any help or suggestions!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Jan 2011 18:48:37 GMT</pubDate>
    <dc:creator>DanielDillard</dc:creator>
    <dc:date>2011-01-14T18:48:37Z</dc:date>
    <item>
      <title>Get Cell Size from Raster Parameter?</title>
      <link>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196270#M15034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to set up a script that takes a raster parameter and a polygon parameter, converts the polygon to raster, and uses the two rasters in the zonal statistics tool.&amp;nbsp; I would like the cell size of the new raster (converted from polygon) to be the same as that of the raster parameter. The describe function does not expose cell size for rasters, and I have no other ideas.&amp;nbsp; Thanks for any help or suggestions!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jan 2011 18:48:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196270#M15034</guid>
      <dc:creator>DanielDillard</dc:creator>
      <dc:date>2011-01-14T18:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get Cell Size from Raster Parameter?</title>
      <link>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196271#M15035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The meanCellHeight and meanCellWidth properties of the raster bands is what you are looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
raster = 'some/path/to/a/raster.tif'
description = arcpy.Describe(raster)
cellsize = description.children[0].meanCellHeight

print cellsize
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The children property is documented under "Describe object properties"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196271#M15035</guid>
      <dc:creator>NiklasNorrthon</dc:creator>
      <dc:date>2021-12-11T09:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get Cell Size from Raster Parameter?</title>
      <link>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196272#M15036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For clarification purposes only, this code will work only in the python window within&amp;nbsp;ArcMap and not within a stand-alone script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to run this in a separate python script (using ArcMap 10.5), you may need to add the creation of the raster element between of the declaration of the path for the raster and the &lt;STRONG&gt;Describe&lt;/STRONG&gt; process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, if I wasn't creating the Raster element first, I would get an error stating that the list index was out of range cause by, according to my tests, the missing &lt;EM&gt;children[0] &lt;/EM&gt;portion of the code above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As such, below is the revised version of the code for usage within a python script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&amp;nbsp; 

rasterpath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'some/path/to/a/raster.tif'&lt;/SPAN&gt;
raster&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Raster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rasterpath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
description &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp; 
cellsize1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; description&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;children&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;meanCellHeight&amp;nbsp; &lt;SPAN class="comment token"&gt;# Cell size in the Y axis and / or &lt;/SPAN&gt;
cellsize2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; description&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;children&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;meanCellWidth &lt;SPAN class="comment token"&gt;# Cell size in the X axis &lt;/SPAN&gt;
 
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cellsize1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# If you want to show the result in the processing window‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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, 11 Dec 2021 09:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-cell-size-from-raster-parameter/m-p/196272#M15036</guid>
      <dc:creator>KenMayner</dc:creator>
      <dc:date>2021-12-11T09:48:26Z</dc:date>
    </item>
  </channel>
</rss>

