<\/HEAD>
Consegui fazer isso funcionar, mas ainda não consigo ver qual era o problema com minha sintaxe python original.<\/P>
<\/P>
Eu queria executar uma análise de água superficial em várias mudanças propostas em uma área para ver quão bem poderíamos prevenir inundações, então peguei um script python de um projeto de 2015 e o modifiquei para rodar em um espaço de trabalho diferente para me ajudar a executar essas etapas em várias superfícies diferentes. <\/P>
<SPAN class="comment token"># -*- coding: utf-8 -*-<\/SPAN>
<SPAN class="comment token"># ---------------------------------------------------------------------------<\/SPAN>
<SPAN class="comment token"># Fill2Stream.py<\/SPAN>
<SPAN class="comment token"># Created on: 2015-03-06 10:28:41.00000<\/SPAN>
<SPAN class="comment token"># (generated by ArcGIS\/ModelBuilder)<\/SPAN>
<SPAN class="comment token"># Description: to generate flow direction and accumulation grids from an elevation raster. <\/SPAN>
<SPAN class="comment token"># Modified 2017-11-28 by PH to run these steps on Mud Lake spillway analysis<\/SPAN>
<SPAN class="comment token"># ---------------------------------------------------------------------------<\/SPAN>
<SPAN class="comment token"># Import arcpy module<\/SPAN>
<SPAN class="keyword token">import<\/SPAN> arcpy
<SPAN class="keyword token">from<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>sa <SPAN class="keyword token">import<\/SPAN> <SPAN class="operator token">*<\/SPAN>
<SPAN class="comment token"># Check out any necessary licenses<\/SPAN>
arcpy<SPAN class="punctuation token">.<\/SPAN>CheckOutExtension<SPAN class="punctuation token">(<\/SPAN><SPAN class="string token">"spatial"<\/SPAN><SPAN class="punctuation token">)<\/SPAN>
arcpy<SPAN class="punctuation token">.<\/SPAN>env<SPAN class="punctuation token">.<\/SPAN>workspace <SPAN class="operator token">=<\/SPAN> <SPAN class="string token">"G:\/elevation\/lidar_2005\/MudLake\/MudLakeTerrians.gdb"<\/SPAN>
arcpy<SPAN class="punctuation token">.<\/SPAN>env<SPAN class="punctuation token">.<\/SPAN>overwrite <SPAN class="operator token">=<\/SPAN> <SPAN class="string token">"True"<\/SPAN>
<SPAN class="comment token"># Local variables:<\/SPAN>
<SPAN class="comment token">#DEMrs = "G:\\elevation\\lidar_2005\\MudLake\\MudLakeTerrians\\DEMFloodway"<\/SPAN>
DEMrs <SPAN class="operator token">=<\/SPAN> <SPAN class="string token">"G:\\elevation\\lidar_2005\\MudLake\\MudLakeTerrians.gdb\\DEMFloodway"<\/SPAN>
<SPAN class="comment token">#DEMrs = "DEMFloodway"<\/SPAN>
Fill <SPAN class="operator token">=<\/SPAN> <SPAN class="string token">"DEMFWfill"<\/SPAN>
flowdir <SPAN class="operator token">=<\/SPAN> <SPAN class="string token">"DEMFWdir"<\/SPAN>
drop_raster <SPAN class="operator token">=<\/span> <span class=\"string token\">\"DEMFWDrop\"</span>
Accum <span class=\"operator token\">=</span> <span class=\"string token\">\"DEMFWaccum\"</span>
<span class=\"keyword token\">print</span> DEMrs
<span class=\"comment token\">#Process: Fill</span>
<span class=\"comment token\">#outFill = Fill(DEMrs)</span>
<span class=\"comment token\">#outFill.save(Fill)</span>
arcpy<span class=\"punctuation token\">.</span>gp<span class=\"punctuation token\">.</span>Fill_sa<span class=\"punctuation token\">(</span>DEMrs<span class=\"punctuation token\">,</span> Fill<span class=\"punctuation token\">,</span> <span class=\"string token\">\"\"</span><span class=\"punctuation token\">)</span>
<span class=\"comment token\"># Process: Flow Direction</span>
arcpy<span class=\"punctuation token\">.</span>gp<span class=\"punctuation token\">.</span>FlowDirection_sa<span class=\"punctuation token\">(</span>Fill<span class=\"punctuation token\">,</span> flowdir<span class=\"punctuation token\">,</span> <span class=\"string token\">\"NORMAL\"</span><span class=\"punctuation token\">,</span> drop_raster<span class=\"punctuation token\">)</span>
<span class=\"comment token\"># Process: Flow Accumulation</span>
arcpy<span class=\"punctuation token\">.</span>gp<span class=\"punctuation token\">.</span>FlowAccumulation_sa<span class=\"punctuation token\">(</span>flowdir<span class=\"punctuation token\">,</span> Accum<span class=\"punctuation token\">,</span> <span class=\"string token\">\"\"</span><span class=\"punctuation token\">,</span> <span class=\"string token\">\"FLOAT\"</span><span class=\"punctuation token\">)</span>
<span class=\"comment token\"># Process stream line rasters</span>
strm <span class=\"operator token\">=</span> Con<span class=\"punctuation token\">\(</span>Raster<span class=\"punctuation token">(</span>Accum<span class=\"punctuation token">\(</span>) > 200000, 1, 0<span class=\""></span>)
strm10 <spanclass="><operatortoken>=</operatortoken></class>= Con(Raster(Accum) > 10000, 1, 0)
strm.save("FWstrm")
strm10.save("FWstrm10")
</P><P>No entanto, cada vez que eu executava isso, recebia "linha 32, no <módulo><BR \/> outFill = Fill(DEMrs)<BR \/>TypeError: 'str' object is not callable".<\/P><P>Então tentei definir DEMrs com e sem o caminho completo, mudar o nome da variável de DEM para DEMrs caso DEM fosse reservado, mudar o nome da variável Fill para outFill, mudar a direção das barras do diretório de \/ para \ e para \\\, e nada parecia funcionar até que mudei a forma da chamada da ferramenta fill de outFill = Fill(DEMrs) para arcpy.gp.Fill_sa(DEMrs, Fill, ""). Estou intrigado por isso ter sido necessário já que a Ajuda parece mostrar a ferramenta Fill em um script python assim:<\/P><DIV><DIVclass="><DIVclass="><DIVclass="><PREclass="><CODE><SPAnclass=>outFill </SPAnclass>= Fill(inSurfaceRaster, zLimit)