|
模型构建主要使用了Archydro工具箱,报错内容也主要是Arc_Hydro_Tools_Pro.tbx(SyntaxError: EOL while scanning string literal (Arc_Hydro_Tools_Pro.tbx, line 6383)
代码如下:
# -*- coding: utf-8 -*-"""Generated by ArcGIS ModelBuilder on : 2021-07-07 17:44:07"""import arcpydef gzq20210706(): # 汇流区划分 # To allow overwriting outputs change overwriteOutput option to True. arcpy.env.overwriteOutput = False arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Arc_Hydro_Tools_Pro.tbx") # Model Environment settings with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): 输入DEM数据 = arcpy.Raster("NXDEM") 输入矢量河流 = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\MyProject1.gdb\\内乡县河流" # Process: 折线转栅格 (折线转栅格) (conversion) 输出FlowlineRaster = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\MyProject1.gdb\\FlowlineRaster" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.conversion.PolylineToRaster(in_features=输入矢量河流, value_field="OBJECTID", out_rasterdataset=输出FlowlineRaster, cell_assignment="MAXIMUM_LENGTH", priority_field="NONE", cellsize="0.0028", build_rat="BUILD") # Process: DEM修复 (DEM Reconditioning) (archydropro) 输出AgreeDEM = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\agreedem" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.DEMReconditioning(Input_Raw_DEM_Raster=输入DEM数据, Input_Stream_Raster=输出FlowlineRaster, Number_of_Cells_for_Stream_Buffer=5, Smooth_Drop_in_Z_Units=10, Sharp_Drop_in_Z_Units=1000, Output_AGREE_DEM_Raster=输出AgreeDEM, Raise_Negative_Values="NEGATIVE_NO") # Process: 填洼填充 (Fill Sinks) (archydropro) 输出Fil = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\fil" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.FillSinks(Input_DEM_Raster=输出AgreeDEM, Output_Hydro_DEM_Raster=输出Fil, Fill_Threshold=None, Input_Deranged_Polygon_Feature_Class="", Use_IsSink_Field="ISSINK_NO") # Process: 水流方向 (Flow Direction) (archydropro) 输出Fdr = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\fdr" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.FlowDirection(Input_Hydro_DEM_Raster=输出Fil, Output_Flow_Direction_Raster=输出Fdr, Input_External_Wall_Polygon_Feature_Class="") # Process: 汇流累积量 (Flow Accumulation) (archydropro) 输出Fac = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\fac" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.FlowAccumulation(Input_Flow_Direction_Raster=输出Fdr, Output_Flow_Accumulation_Raster=输出Fac) # Process: 河网结构定义 (Stream Definition) (archydropro) 输出Str = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\str" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.StreamDefinition(Input_Flow_Accumulation_Raster=输出Fac, Number_of_cells_to_define_stream=153796, Output_Stream_Raster=输出Str, Area_SqKm_to_define_stream=None) # Process: 河流弧段提取 (Stream Segmentation) (archydropro) 输出StrLnk = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\strlnk" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.StreamSegmentation(Input_Stream_Raster=输出Str, Input_Flow_Direction_Raster=输出Fdr, Output_Stream_Link_Raster=输出StrLnk, Input_Sink_Watershed_Raster="", Input_Sink_Link_Raster="") # Process: 生产矢量河流线 (Drainage Line Processing) (archydropro) 输出DrainageLine = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\MyProject1.gdb\\Layers\\DrainageLine" 输出DrainageLine_FS = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\MyProject1.gdb\\DrainageLine_FS" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.DrainageLineProcessing(Input_Stream_Link_Raster=输出StrLnk, Input_Flow_Direction_Raster=输出Fdr, Output_Drainage_Line_Feature_Class=输出DrainageLine, Output_Drainage_Line_Flow_Split_Table=输出DrainageLine_FS) # Process: 汇流区生成 (Catchment Grid Delineation) (archydropro) 输出Cat = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\Layers\\cat" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.CatchmentGridDelineation(Input_Flow_Direction_Raster=输出Fdr, Input_Link_Raster=输出StrLnk, Output_Catchment_Raster=输出Cat) # Process: 矢量汇流区生成 (Catchment Polygon Processing) (archydropro) 输出Catchment = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\MyProject1.gdb\\Layers\\Catchment" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.CatchmentPolygonProcessing(Input_Catchment_Raster=输出Cat, Output_Catchment_Feature_Class=输出Catchment) # Process: 提取流域出水口 (Drainage Point Processing) (archydropro) 输出DrainagePoint = "C:\\Users\\Administrator\\Desktop\\内乡县\\MyProject1\\MyProject1.gdb\\Layers\\DrainagePoint" with arcpy.EnvManager(scratchWorkspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb", workspace=r"C:\Users\Administrator\Desktop\内乡县\MyProject1\MyProject1.gdb"): arcpy.archydropro.DrainagePointProcessing(Input_Flow_Accumulation_Raster=输出Fac, Input_Catchment_Raster=输出Cat, Input_Catchment_Feature_Class=输出Catchment, Output_Drainage_Point_Feature_Class=输出DrainagePoint)if __name__ == '__main__': gzq20210706()
报错内容如下:
---------------------------------------------------------------------------SyntaxError Traceback (most recent call last)In [1]ine 75: gzq20210706()In [1]:Line 12: arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Arc_Hydro_Tools_Pro.tbx")File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py, in ImportToolbox:Line 185: return import_toolbox(input_file, module_name)File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\toolbox_code.py, in import_toolbox:Line 491: mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias)File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\toolbox_code.py, in generate_toolbox_module:Line 466: 'exec')SyntaxError: EOL while scanning string literal (Arc_Hydro_Tools_Pro.tbx, line 6383)---------------------------------------------------------------------------
|
|