Právě přepisuji následující Python modul:<\/P>
<\/P>
Právě jsem si uvědomil, že ArcHydro nerozpoznává arcpy.env.workspace ani ArcHydroTools.SetTargetLocations("HydroConfig", "Layers", "RasterWorkspace", "VectorWorkspace")<\/P>
<SPAN class="string token">''' Vytvořeno 13. března 2017 Hlavní model ArcHydro @author: PeterW '''<\/SPAN> <SPAN class="comment token"># import systémových modulů a site-packages<\/SPAN> <SPAN class="keyword token">from<\/SPAN> pathlib <SPAN class="keyword token">import<\/SPAN> Path <SPAN class="keyword token">import<\/SPAN> arcpy <SPAN class="keyword token">import<\/SPAN> ArcHydroTools <SPAN class="comment token"># nastavit argumenty<\/SPAN> rasters_workspace <SPAN class="operator token">=<\/SPAN> r<SPAN class="string token">"E:\Projects\2016\G113386\ArcHydro\Model01\Layers01"<\/SPAN> dem <SPAN class="operator token">=<\/SPAN> r<SPAN class="string token">"E:\Projects\2016\G113386\DEM\raw"<\/SPAN> fgdb_workspace <SPAN class="operator token">=<\/SPAN> r<SPAN class="string token">"E:\Projects\2016\G113386\ArcHydro\Model01\Model01.gdb"<\/SPAN> <SPAN class="comment token"># zkontrolovat rozšíření a nastavit prostředí<\/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>overwriteOutput <SPAN class="operator token">=<\/SPAN> <SPAN class="token boolean">True<\/SPAN> <SPAN class="keyword token">def<\/SPAN> <SPAN class="token function">rasters_main<\/SPAN><SPAN class="punctuation token">(<\/SPAN>rasters_workspace<SPAN class="punctuation token">, <\/SPAN>dem<SPAN class="punctuation token">)<\/SPAN><SPAN class="punctuation token">:<\/SPAN> <SPAN class="string token">""" Vytvořit rastrové vrstvy jako součást ArcHydro předzpracování"""<\/SPAN> <SPAN class="comment token"># nastavit raster workspace<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>env<SPAN class="punctuation token">.<\/SPAN>workspace <SPAN class="operator token">=<\/SPAN> rasters_workspace <SPAN class="comment token"># nastavit ArcHydro cílové lokace pro rastrová a vektorová data<\/SPAN> ArcHydroTools<SPAN class="punctuation token">.<\/SPA... (truncated) ...rchyTools.SetTargetLocations ignorovány ArcHydro.<\/P><P><\/P><PRE class="lia-code-sample line-numbers language-none"><CODE>Zpracovávám Fill Sinks Traceback <span class="punctuation token">(<span>nejnovější volání poslední<span>)</span></span>: Soubor <span class="string token">"E:\Python\Eclipse\2015\arcpy64bit\src\archydro\archydro_main_test.py"</span>, řádek 34, ve <span class="keyword token">modulu</span> rasters_main(rasters_workspace, dem) Soubor <span class="string token">"E:\Python\Eclipse\2015\arcpy64bit\src\archydro\archydro_main_test.py"</span>, řádek 31, ve funkci rasters_main ArcHydroTools.FillSinks(dem, "fil") Soubor <span class="string token">"C:\Program Files\ESRI\WaterUtils\ArcHydro\bin\ArcHydroTools.py"</span>, řádek 6805, ve FillSinks raise e arcgisscripting.ExecuteError: Musíte nastavit buď geoprocessing Workspace nebo Arc Hydro Raster Location před spuštěním nástroje. Nepodařilo se spustit (FillSinks). <span class='line-numbers-rows'><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span>
Zpráva o chybě:<\/P>
<\/P><\/BODY><\/HTML>
I don't know if this will fix your problem, but I was having a similar issue (except with vector location instead of raster location) with ThinCrossSection tool even though I set the arcpy enviroment and ArcHydro's target locations.
The issue seems to be that you need a full path to a feature instead of just the name:
<SPAN class="comment token"># This did not work for me</SPAN> ArcHydroTools<SPAN class="punctuation token">.</SPAN>ThinCrossSection<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"TEMP"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MaxNumberOfVertices"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN> output<SPAN class="punctuation token">,</SPAN> report<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># This did</SPAN> output <SPAN class="operator token">=</SPAN> gdb_path <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\\'</SPAN> <SPAN class="operator token">+</SPAN> output report <SPAN class="operator token">=</SPAN> gdb_path <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\\'</SPAN> <SPAN class="operator token">+</SPAN> report ArcHydroTools<SPAN class="punctuation token">.</SPAN>ThinCrossSection<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"TEMP"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MaxNumberOfVertices"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN> output<SPAN class="punctuation token">,</SPAN> report<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
And with this, I just had to set the arcpy workspace - I don't need to call SetTargetLocations from ArcHydro.
So specifically for yours, replacing 'fil' in the FillSinks call with the full path to 'fil' might work
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.