ArcHydro script problem

624
1
04-14-2013 12:30 PM
SALIFOUMAMAR
New Contributor
I need some help with archydro scripting. I designed my code to automate archydro process; the script runs without error message, but no result. I tried my all the suggestions on the forum but no luck.  Is it how my code is structured or I am missing some in my code? Here is my code:

import arcpy, sys, string, os, ArcHydroTools
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True        
arcpy.env.workspace = "C:/Temp/" #arcpy.GetParameterAsText(0)
class myArcHydro:
    def myInputDESC(inputDEM):
        desc = arcpy.Describe(inputDEM)
        print desc.format
        if desc.format != 'GRID':
            arcpy.ASCIIToRaster_conversion(inputDEM, outputDEM, "FLOAT")

    def projCheck():
        dataSpatRef = arcpy.Describe(inputDEM).spatialReference
        if dataSpatRef.Type != "Projected":
            arcpy.AddError("Error: " + inputDEM + " must have a projected coordinate system")


    def myArcHydroTools(inputDEM, outputSHP, outputDIR):
        # Check out any necessary licenses and toolboxes
         arcpy.CheckOutExtension("spatial")
         #ArcHydroTools.AssignHydroID(tmpPolyFC, "OVERWRITE_YES")
         for dem in inputDEM:
             # Output Filenames
             Fil = outputDIR + "/fil"
             Fdr = outputDIR + "/fdr"
             Fac = outputDIR + "/fac"
             Str = outputDIR + "/str"
             StrLnk = outputDIR + "/strlnk"
             Cat = outputDIR + "/cat"
             Catchment = outputDIR + "/Catchment"
             DrainageLine = outputDIR + "/DrainageLine"
             AdjointCatchment = outputDIR + "/AdjointCatchment"
             DrainagePoint = outputDIR + "/DrainagePoint"

             # Run processes
             try:
                 ArcHydroTools.FillSinks(inputDEM, Fil)
                 ArcHydroTools.FlowDirection(Fil, Fdr)
                 ArcHydroTools.FlowAccumulation(Fdr, Fac)
                 ArcHydroTools.StreamDefinition(Fac, "", Str)
                 ArcHydroTools.StreamSegmentation(Str, Fdr, StrLnk)
                 ArcHydroTools.DrainageLineProcessing(StrLnk, Fdr, DrainageLine)
                 ArcHydroTools.CatchmentGridDelineation(Fdr, StrLnk, Cat)
                 ArcHydroTools.CatchmentPolyProcessing(Cat, Catchment)
                 ArcHydroTools.AdjointCatchment(DrainageLine, Catchment, AdjointCatchment)
                 ArcHydroTools.DrainagePointProcessing(Fac, Cat, Catchment, DrainagePoint)
                
             except:
                   arcpy.AddWarning("ERROR. An error has occurred during processing.")


if __name__ == '__main__':
     inputFile = arcpy.GetParameterAsText(0)
     outputFile = arcpy.GetParameterAsText(1)
     outputDIR = arcpy.GetParameterAsText(2)
     # Call the myArcHydroTools function.

     myArcHydroTools(inputFile, outputFile, outputDIR)
     print "success"

Any adept of ArcHydro out there that can help?
0 Kudos
1 Reply
MarkBoucher
Regular Contributor II
I'm behind you on the arcpy script learning curve and look on with envy and interest.

Some thoughts...

Have your target locations been set? Maybe the results are output to some other yet to be discovered folder.

I see you have the user input the "outputDIR". Remember: the rasters go into a folder with same name as the dataframe and the vector data goes into a geodatabase with the same name as the file and a dataset with the same name as the dataframe. This is my understanding of the the Arc Hydro default. The geodatabase name may not be that important, but Arc Hydro uses the network feature and that requires the use of the geodatabase. Therefore, having everything simply go to an "outputDIR" may not set up the vector data for the network functions.
0 Kudos