<?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 Raster object loses methods after calculations in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/raster-object-loses-methods-after-calculations/m-p/1272606#M67267</link>
    <description>&lt;P&gt;I am doing some work with multidimensional rasters in a Python notebook.&amp;nbsp; I've run into some problems with this workflow.&lt;/P&gt;&lt;P&gt;The current one is that methods appear to not be maintained through raster calculator calcuations.&lt;/P&gt;&lt;P&gt;Example code with error&lt;/P&gt;&lt;LI-CODE lang="c"&gt;temp_max_file = r"c:\GridMetData_2020\tmmx_2020.nc"
temp_min_file = r"C:\GridMetData_2020\tmmn_2020.nc"
max_temp_rast = arcpy.Raster(temp_max_file,True)
min_temp_rast = arcpy.Raster(temp_min_file,True)
DD5_conus = ((max_temp_rast - min_temp_rast)/2)-5
DD5_gt0_conus = arcpy.sa.Con(DD5_conus &amp;gt; 0.0, DD5_conus, 0.0)
DD5_gt5c_conus = arcpy.sa.Con(DD5_conus &amp;gt; 5.0, DD5_gt0_conus, 0.0)
DD5_gt5c_conus.mean()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
In  [25]:
Line 1:     DD5_gt5c_conus.mean()

RuntimeError: Unspecified error 
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some of the same functionality is available with the aggregateMultidimensionalRaster too,&lt;/P&gt;&lt;P&gt;This is however a unpythonic solution and add another level of commplextiyh to the cocde.&lt;/P&gt;&lt;P&gt;Any ideas on how to keep the object methods as the object groes through calculations?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2023 17:38:28 GMT</pubDate>
    <dc:creator>DavidAnderson_1701</dc:creator>
    <dc:date>2023-03-28T17:38:28Z</dc:date>
    <item>
      <title>Raster object loses methods after calculations</title>
      <link>https://community.esri.com/t5/python-questions/raster-object-loses-methods-after-calculations/m-p/1272606#M67267</link>
      <description>&lt;P&gt;I am doing some work with multidimensional rasters in a Python notebook.&amp;nbsp; I've run into some problems with this workflow.&lt;/P&gt;&lt;P&gt;The current one is that methods appear to not be maintained through raster calculator calcuations.&lt;/P&gt;&lt;P&gt;Example code with error&lt;/P&gt;&lt;LI-CODE lang="c"&gt;temp_max_file = r"c:\GridMetData_2020\tmmx_2020.nc"
temp_min_file = r"C:\GridMetData_2020\tmmn_2020.nc"
max_temp_rast = arcpy.Raster(temp_max_file,True)
min_temp_rast = arcpy.Raster(temp_min_file,True)
DD5_conus = ((max_temp_rast - min_temp_rast)/2)-5
DD5_gt0_conus = arcpy.sa.Con(DD5_conus &amp;gt; 0.0, DD5_conus, 0.0)
DD5_gt5c_conus = arcpy.sa.Con(DD5_conus &amp;gt; 5.0, DD5_gt0_conus, 0.0)
DD5_gt5c_conus.mean()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
In  [25]:
Line 1:     DD5_gt5c_conus.mean()

RuntimeError: Unspecified error 
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some of the same functionality is available with the aggregateMultidimensionalRaster too,&lt;/P&gt;&lt;P&gt;This is however a unpythonic solution and add another level of commplextiyh to the cocde.&lt;/P&gt;&lt;P&gt;Any ideas on how to keep the object methods as the object groes through calculations?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 17:38:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-object-loses-methods-after-calculations/m-p/1272606#M67267</guid>
      <dc:creator>DavidAnderson_1701</dc:creator>
      <dc:date>2023-03-28T17:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Raster object loses methods after calculations</title>
      <link>https://community.esri.com/t5/python-questions/raster-object-loses-methods-after-calculations/m-p/1275317#M67343</link>
      <description>&lt;P&gt;Can you check back on what &lt;FONT face="terminal,monaco" size="2"&gt;type(obj)&lt;/FONT&gt; shows for your earlier calls? My guess is one of those did not get dynamically cast to a Raster object and assumed a scalar operation. If you explicitly cast, it should work, e.g. in your last step request a new &lt;FONT face="terminal,monaco" size="2"&gt;DD5_gt5c_conus_rast = arcpy.Raster(DD5_gt5c_conus)&lt;/FONT&gt;.&lt;BR /&gt;&lt;BR /&gt;Cheers, Shaun&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:29:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-object-loses-methods-after-calculations/m-p/1275317#M67343</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2023-04-04T15:29:30Z</dc:date>
    </item>
  </channel>
</rss>

