Error Trapping: ArcHydro LongestFlowPath

2490
2
05-20-2013 09:38 AM
Labels (1)
PeterWilson
Occasional Contributor III
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.

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')


I've tried the following approach, but over write output doesn't work:

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


Any help will be appreciated.

Regards
Tags (2)
0 Kudos
2 Replies
ChristineDartiguenave
Esri Contributor
We have modified the function so that it now runs through all selected input features and report the issues at the end (10.1.0.160). Give it a try.

Christine

Christine Dartiguenave
Esri Water Resources Team
0 Kudos
PeterWilson
Occasional Contributor III
Thanks Christine

Appreciate the following, I'll rerun the following section and let you know.

Regards
0 Kudos