I've a very large model where I'm processing 650 watersheds. My model is failing when trying to generate the longest flow paths for the 650 watersheds. I would like to trap the individual watersheds that are causing the longest flow path to fail, report the hydroID and continue the the rest of the watersheds at least. I can always go back to look at the watersheds that throw an exception to see whats causing the the tool to fail.
I've tried the following approach, but over write output doesn't work:
Any help will be appreciated.
Regards
Code:
import arcpy, ArcHydroTools
watshed = r'E:\Projects\H109355_2\ArcHydro\Model3\Nigeria03.gdb\Layers\Watershed'
fdr = r'E:\Projects\H109355_2\Archydro\GRID\layers.gdb\Fdr'
ArcHydroTools.LongestFlowpath(watshed,fdr,r'E:\Projects\H109355_2\ArcHyro\Model3\Nigeria03.gdb\Layers\LongestFlowPath')
Code:
import arcpy, ArcHydroTools
outpath = arcpy.env.workspace = r'E:\Projects\H109355_2\ArcHydro\Model3\Nigeria03.gdb\Layers'
arcpy.env.overwriteOutput = True
fdr = r'E:\Projects\H109355_2\ArcHydro\GRID\Layers.gdb\Fdr'
watshed = "Watershed"
with arcpy.da.SearchCursor(watshed,("Name",)) as scur:
for row in scur:
cuindex = row[0]
sqlexp = """{0} = '{1}'""".format(arcpy.AddFieldDelimiters(watshed,"Name"),cuindex)
watshedind = arcpy.FeatureClassToFeatureClass_conversion(watshed,outpath,"watshed",sqlexp)
try:
longflowpath1 = ArcHydroTools.LongestFlowPath(watshedind,fdr,"in_memory\longestflowpath")
except:
arcpy.AddMessage
print cuindex
Regards