現在、以下のPythonモジュールを書き直しています:<\/P>
<\/P>
ArcHydroがarcpy.env.workspaceやArcHydroTools.SetTargetLocations("HydroConfig", "Layers", "RasterWorkspace", "VectorWorkspace")を認識しないことに気づきました<\/P>
PythoN Module: arcpy.env.workspace と ArcHydroTools.SetTargetLocations は ArcHydro によって無視されます<pre>Processing Fill SinksTraceback (most recent call last): File "E:\Python\Eclipse\2015\arcpy64bit\src\archydro\archydro_main_test.py", line 34, in <module> rasters_main(rasters_workspace, dem) File "E:\Python\Eclipse\2015\arcpy64bit\src\archydro\archydro_main_test.py", line 31, in rasters_main ArcHydroTools.FillSinks(dem, "fil") File "C:\Program Files\ESRI\WaterUtils\ArcHydro\bin\ArcHydroTools.py", line 6805, in FillSinks raise earcgisscripting.ExecuteError: ツールを実行する前に、ジオプロセシングWorkspaceまたはArc Hydro Raster Locationのいずれかを設定する必要があります。Failed to execute (FillSinks).>}>}>}>}>}>}>}>}>}>}>}>}Error Message:PythoN Module: arcpy.env.workspace と ArcHydroTools.SetTargetLocations は ArcHydro によって無視されます<SPAN class="string token">''' 2017年3月13日作成 ArcHydroメインモデル @author: PeterW '''<\/SPAN> <SPAN class="comment token"># システムモジュールと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"># 引数の設定<\/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"># エクステンションのチェックアウトと環境設定の設定<\/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">""" ArcHydro Pre-processingの一部としてラスターを作成する"""<\/SPAN> <SPAN class="comment token"># ラスター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"># RasterおよびVectorデータセット用のArcHyro Target Locationsを設定する<\/Span> ArcHydroTools<Span class="punctuation token">.<\/span>SetTargetLocations<span class="punctuation token">(<span class="string token">"HydroConfig"</span>, <span class="string token">"Layers"</span>, rasters_workspace, fgdb_workspace)<span class="punctuation token"></span> <span class="comment token"># Fill Sinksラスターを作成する</span> arcpy<span class="punctuation token">.<span>AddMessage</span>(</span><span class="string token">"Processing Fill Sinks"</span><span class="punctuation token">)</span> ArcHydroTools<span class="punctuation token">.<span>FillSinks</span>(</span>dem, <span class="string token">"fil"</span><span class="punctuation token">)</span> <span class="comment token"># Flow Directionラスターを作成する</span> rasters_main(rasters_workspace, dem)<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></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><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span}><}</spam<<emojI34>>}<spam<<emojI35>>}<spam<<emojI36>>}</spam>
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
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.