<?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: listRasters flowaccumulation ArcGIS9.3.1 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646135#M50381</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If your call to ListRasters is truly returning a list, then you'll want to use a for loop instead of a while. I'd also change the outRaster assignment to make a little more robust:&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for ras in rasList:
&amp;nbsp; outRaster = os.path.join(outFolder,ras)
&amp;nbsp; # Process: Flow Accumulation...
&amp;nbsp; print ras
&amp;nbsp; gp.FlowAccumulation_sa(inFD, outRaster, ras, "INTEGER")
&amp;nbsp; # Move on to next grid in the list 
&lt;/PRE&gt;&lt;SPAN&gt;There will be no further need for either 'ras = rasList.next()' statement.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:25:42 GMT</pubDate>
    <dc:creator>BruceNielsen</dc:creator>
    <dc:date>2021-12-12T03:25:42Z</dc:date>
    <item>
      <title>listRasters flowaccumulation ArcGIS9.3.1</title>
      <link>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646134#M50380</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;SPAN&gt;I am new to Python. When I run my script from toolbox nothing happens. But when I step through it in PythonWin I get the error: AttributeError: 'list' object has no attribute 'next'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys, string, os, arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Create the Geoprocessor object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Check out any necessary licenses&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CheckOutExtension("spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#input workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inWS = gp.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#output folder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outFolder = gp.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#input flowdir&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inFD = gp.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set the workspace where the output folder is&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = inWS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage("Input workspace")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage(inWS)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage("Output workspace")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage(outFolder)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage("flow direction")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage(inFD)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Python will overwrite exsisting outputfiles&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.overwriteoutput = 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Load required toolboxes...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.AddToolbox("C:\Program Files (x86)\ArcGIS\ArcToolBox\Toolboxes/Spatial Analyst Tools.tbx")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Get a list of the tables in the input folder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rasList = gp.ListRasters("*", "GRID")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Loop through the list of rasters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ras = rasList.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while ras:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = outFolder + "/" + ras&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Flow Accumulation...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ras&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.FlowAccumulation_sa(inFD, outRaster, ras, "INTEGER")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Move on to next grid in the list&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ras = rasList.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Esther&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 10:55:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646134#M50380</guid>
      <dc:creator>EstherJensen</dc:creator>
      <dc:date>2011-08-16T10:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: listRasters flowaccumulation ArcGIS9.3.1</title>
      <link>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646135#M50381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If your call to ListRasters is truly returning a list, then you'll want to use a for loop instead of a while. I'd also change the outRaster assignment to make a little more robust:&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for ras in rasList:
&amp;nbsp; outRaster = os.path.join(outFolder,ras)
&amp;nbsp; # Process: Flow Accumulation...
&amp;nbsp; print ras
&amp;nbsp; gp.FlowAccumulation_sa(inFD, outRaster, ras, "INTEGER")
&amp;nbsp; # Move on to next grid in the list 
&lt;/PRE&gt;&lt;SPAN&gt;There will be no further need for either 'ras = rasList.next()' statement.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:25:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646135#M50381</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2021-12-12T03:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: listRasters flowaccumulation ArcGIS9.3.1</title>
      <link>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646136#M50382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;it seems to work better but it am still getting errors: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000876: Output accumulation raster: V:\python\output\Q2.asc's extension is invalid for the output raster format.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried to use both ascii rasters and ESRI GRID.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 14:16:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listrasters-flowaccumulation-arcgis9-3-1/m-p/646136#M50382</guid>
      <dc:creator>EstherJensen</dc:creator>
      <dc:date>2011-08-16T14:16:53Z</dc:date>
    </item>
  </channel>
</rss>

