<?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: Iteration with &amp;quot;For&amp;quot; does not works for Raster Object in Arcgis Pro 2.5 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296529#M22901</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Dan,&lt;/P&gt;&lt;P&gt;yes, it was an error when I pasted&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The line was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LR = arcpy.ListRasters(*SR_clip*)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so, it was the reason just rasters names&amp;nbsp; were listed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the error occurs when I try to do any math operation using Raster object, script works for the first image, after that the error occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Mar 2020 01:49:08 GMT</pubDate>
    <dc:creator>Jhon_EricAunta</dc:creator>
    <dc:date>2020-03-28T01:49:08Z</dc:date>
    <item>
      <title>Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296527#M22899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I was trying to iterate through folder with rasters for some calculations between the bands of each one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a script that is stored in a toolbox and ask for couple of parameters. when I run the script, it makes the process for the first image but after that it does not works for the next one and the following error appears:&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/486421_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should mention that I tried the same but running the script as stand-alone using the python command promt and it works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I tried something easy in the python window in ArcgisPRO:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy.sa import *&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import os&lt;BR /&gt;arcpy.env.workspace = 'C:\\Imagenes_Satelitales\\2018\\Junio\\Poligono3'&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;LR = arcpy.ListSpatialReferences('*SR_clip*')&lt;BR /&gt;LR&lt;BR /&gt;&lt;SPAN style="color: #999999;"&gt;['20180607_145218_0f4e_3B_AnalyticMS_SR_clip.tif', '20180607_145219_0f4e_3B_AnalyticMS_SR_clip.tif', '20180607_145220_0f4e_3B_AnalyticMS_SR_clip.tif']&lt;/SPAN&gt;&lt;BR /&gt;for raster in LR:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;#getting bands&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Image = Raster(raster)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;b3 = Image.getRasterBands()[2]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;b4 = Image.getRasterBands()[3]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = arcpy.sa.Float(b4 - b3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;name = os.path.splitext(raster)[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;result.save(os.path.join('C:\\Imagenes_Satelitales\\2018\\Junio\\Poligono3', name + 'result.tif')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #993300;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #993300;"&gt; File "&amp;lt;string&amp;gt;", line 3, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #993300;"&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sa\Raster.py", line 79, in __new__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #993300;"&gt; return super().__new__(cls, in_raster, is_multidimensional)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #993300;"&gt;RuntimeError: ERROR 000732: Input Raster: Dataset 20180607_145218_0f4e_3B_AnalyticMS_SR_clip.tif does not exist or is not supported&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That type of error is the same that I got when I run the complete script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For now, I am going to continue using the python command promt for running the script but I would like to do it from the toolbox that I have for that purpose.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jhon Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Mar 2020 23:35:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296527#M22899</guid>
      <dc:creator>Jhon_EricAunta</dc:creator>
      <dc:date>2020-03-27T23:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296528#M22900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is this line in error?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;LR = arcpy.ListSpatialReferences('*SR_clip*')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;yet the *.tif files are listed and not the spatial references?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;will provide line numbers.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Mar 2020 00:48:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296528#M22900</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-03-28T00:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296529#M22901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Dan,&lt;/P&gt;&lt;P&gt;yes, it was an error when I pasted&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The line was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LR = arcpy.ListRasters(*SR_clip*)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so, it was the reason just rasters names&amp;nbsp; were listed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the error occurs when I try to do any math operation using Raster object, script works for the first image, after that the error occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Mar 2020 01:49:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296529#M22901</guid>
      <dc:creator>Jhon_EricAunta</dc:creator>
      <dc:date>2020-03-28T01:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296530#M22902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you follow the path to the Raster.py script in the&amp;nbsp;C:\...your installation folder... \Resources\ArcPy\arcpy\sa&lt;/P&gt;&lt;P&gt;I am wondering if it doesn't like what it is finding in the files in terms of the number of bands, the band numbers/names.&amp;nbsp; Of course, I am assuming that it isn't a multidimensional raster not to be confused with a multiband raster.&lt;/P&gt;&lt;P&gt;I would suggest that you throw in a few lines to print out some of the raster properties to confirm what is actually in there.&amp;nbsp; There is nothing in the code that would fail unless it was getting something it wasn't expecting (at least at first glance).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Mar 2020 02:06:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296530#M22902</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-03-28T02:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296531#M22903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;Hi everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;Thank you for bringing this up &lt;SPAN style="background-color: #ffffff;"&gt;Jhon Eric&lt;/SPAN&gt;. I'm having this same issue, trying to iterate through rasters in a geodatabase, in Arc Pro 2.5. I am able to successfully output the first raster in my list, but it fails on the second time around.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="489656" class="image-1 jive-image" height="199" src="https://community.esri.com/legacyfs/online/489656_pastedImage_8.png" width="675" /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;# text version&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;def convert_depth_raster(self, parameters):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.env.workspace = self.gdb_out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;db_rasters = arcpy.ListRasters("*")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;print("Converting depth bands: ", db_rasters)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for r in db_rasters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;convert = ((1.4661 * 182329)/(2 * arcpy.sa.Raster(r) * 1.732)) / 1852&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lnm_name = r.replace('DepthBand', 'LNM')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lnm_out =&amp;nbsp;self.gdb_out + "\\" + lnm_name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;convert.save(lnm_path)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 15px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print("Created: ", lnm_out)&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN class="" style="color: #de2900; background-color: #ffffff; text-decoration: none; padding: 0px 0px 0.25rem;"&gt;
Traceback (most recent call last):   File "&amp;lt;string&amp;gt;", line 257, in execute   File "&amp;lt;string&amp;gt;", line 234, in convert_depth_raster   File "c:\users\matt sharr\appdata\local\programs\arcgis\pro\Resources\arcpy\arcpy\sa\Raster.py", line 79, in __new__     return super().__new__(cls, in_raster, is_multidimensional) RuntimeError: &lt;/SPAN&gt;&lt;SPAN class="" style="color: #333333; background-color: #ffffff; margin: 0px 4px 0px 0px; padding: 0px 0px 0.25rem;"&gt;&lt;/SPAN&gt;&lt;A style="color: #de2900; background-color: #ffffff; text-decoration: underline; padding: 0px 0px 0.25rem;" target="_blank"&gt;ERROR 000732:&lt;/A&gt;&lt;SPAN class="" style="color: #de2900; background-color: #ffffff; text-decoration: none; padding: 0px 0px 0.25rem;"&gt; Input Raster: Dataset DepthBand_21_40 does not exist or is not supported

&lt;SPAN style="color: #000000;"&gt;Are there any known solutions at this time? Are there other workarounds besides model builder and manually iterating?

Thank you,&lt;/SPAN&gt;
&lt;SPAN style="color: #000000;"&gt;-Matt&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:13:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296531#M22903</guid>
      <dc:creator>matthewsharr</dc:creator>
      <dc:date>2021-12-11T14:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296532#M22904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try passing the full path of the rasters and not relying on behind-the-scenes path concatenation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 15:17:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296532#M22904</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-04-23T15:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296533#M22905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That did it. Thanks, Joshua.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 21:11:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296533#M22905</guid>
      <dc:creator>matthewsharr</dc:creator>
      <dc:date>2020-04-23T21:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration with "For" does not works for Raster Object in Arcgis Pro 2.5</title>
      <link>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296534#M22906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Should the approach you originally took work?&amp;nbsp; Probably, but I consider it a best practice to always use full paths with geoprocessing tools.&amp;nbsp; Not only does doing so reduce the risk of running into odd defects like this, it simplifies troubleshooting because there is no guessing what was passed to the geoprocessing tools.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 21:47:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iteration-with-quot-for-quot-does-not-works-for/m-p/296534#M22906</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-04-23T21:47:00Z</dc:date>
    </item>
  </channel>
</rss>

