AnsweredAssumed Answered

Example of script correctly running Longest Flow Path tool

Question asked by Thomas.Taggart_NHDES on Nov 30, 2017

Hello, 

 

I am working on trying to do some batch watershed processing.

 

I have watersheds created using ArcHydro, and was trying to run the Longest Flow Path tool in a batch method, on different feature classes (watershed polygons) in a feature dataset, using the code below:

# import stuff
import arcpy, os, traceback, sys, time
import ArcHydroTools

arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput="TRUE"

arcpy.env.workspace="C://Entire_State//Souhegan_River//Souhegan_River.gdb"

Flow_Dir_Grid = "C://Entire_State//Souhegan_River//Layers//fdr"

feat_classes = arcpy.ListFeatureClasses()
for feat in feat_classes:

    try:
        in_name = arcpy.env.workspace + "//Watersheds_Separate//" str(feat)
        out_name = arcpy.env.workspace + "//Watersheds_Separate//" str(feat) + "_LFP"
        ArcHydroTools.LongestFlowPath(in_name,Flow_Dir_Grid,out_name)

    except:
        name = feat + "_LFP"
        message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]
        message = "Python Error Info: " + str(sys.exc_type) + ": " + str(sys.exc_value) + "\n"

arcpy.AddMessage("Done generating LFPs.")
arcpy.CheckInExtension("Spatial")

 

 

And I get this error:   "The default vector location () cannot be a directory. Modify the current geoprocessing workspace or set the Arc Hydro target locations. Failed to execute (LongestFlowPath)."

 

I don't really understand this error and how to fix it - would someone advise or provide an example of a working script that access this tool correctly?

Outcomes