<?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 Error with Calculate Statistics in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138245#M10804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A program that I created has a loop that runs and it constantly lowers the values of a flow accumulation Raster. There gets to a point where the Raster should hit the value zero or no data. The raster comes out with a positive big number and a negative big number, which messes&amp;nbsp;up the&amp;nbsp;calculate statistics function in the loop. Here it is below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/366569_Capture10.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;This is an example of the error I would receive&lt;BR /&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/366570_Capture11.PNG" style="width: 620px; height: 216px;" /&gt;&lt;/P&gt;&lt;P&gt;Is there a way I can create an if statement in the loop to check for a raster that looks like this and break away from the loop?&amp;nbsp;Something like this but a statement that would work.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-3 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/366571_Capture12.PNG" style="width: 620px; height: 244px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Aug 2017 19:29:37 GMT</pubDate>
    <dc:creator>AndrewMartin8</dc:creator>
    <dc:date>2017-08-10T19:29:37Z</dc:date>
    <item>
      <title>Error with Calculate Statistics</title>
      <link>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138245#M10804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A program that I created has a loop that runs and it constantly lowers the values of a flow accumulation Raster. There gets to a point where the Raster should hit the value zero or no data. The raster comes out with a positive big number and a negative big number, which messes&amp;nbsp;up the&amp;nbsp;calculate statistics function in the loop. Here it is below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/366569_Capture10.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;This is an example of the error I would receive&lt;BR /&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/366570_Capture11.PNG" style="width: 620px; height: 216px;" /&gt;&lt;/P&gt;&lt;P&gt;Is there a way I can create an if statement in the loop to check for a raster that looks like this and break away from the loop?&amp;nbsp;Something like this but a statement that would work.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-3 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/366571_Capture12.PNG" style="width: 620px; height: 244px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 19:29:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138245#M10804</guid>
      <dc:creator>AndrewMartin8</dc:creator>
      <dc:date>2017-08-10T19:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Calculate Statistics</title>
      <link>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138246#M10805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume that you are running this in the Python Window inside a session of ArcMap and the raster is present in the TOC. Otherwise, I guess you wouldn't find a raster only by its name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use a try except to catch any errors:&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
fa &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"facheck_102"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fa &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fa&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateStatistics_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fa&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; Exception &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ERR:"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; e&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:39:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138246#M10805</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T07:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Calculate Statistics</title>
      <link>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138247#M10806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also use&amp;nbsp;&lt;A class="link-titled" href="https://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/get-raster-properties.htm" title="https://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/get-raster-properties.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Get Raster Properties—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;with the "ALLNODATA" option to test for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fa &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GeoNet\TestNull\myras.tif'&lt;/SPAN&gt;
test &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetRasterProperties_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fa&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ALLNODATA"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
test &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;test&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&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="keyword token"&gt;if&lt;/SPAN&gt; test &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Raster contains all NoData pixels..."&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Not all pixels are NoData..."&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-calculate-statistics/m-p/138247#M10806</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T07:39:53Z</dc:date>
    </item>
  </channel>
</rss>

