0

I want to create python script with aim to import him in environment arcmap 10.1 and to make a hydrologic analysis

because the scipt meybe can have many outputs raster file or feature class would like to find a way for automatic save outputs variables in the folder workspace

for example

I want to import a raster file (Dem) and to take as export a 3 raster file from the command fill sinks, Fill Sinks,flow directions and flow accumulation from arc hydro toolbox

cl = my import dem
fill = output for Fill Sinks
fdr = output for flow directions
Fac = output for flow accumulation

and i want export them(3 raster) automatically saved to the folder workspace without definitive output parameters from the user

import arcpy

arcpy.ImportToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Arc Hydro Tools.tbx", "archydrotools")

# Local variables:
arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
arcpy.env.workspace = arcpy.GetParameterAsText(0)
cl = arcpy.GetParameterAsText(1)
# Process: Fill Sinks
arcpy.FillSinks_archydrotools(cl, fill, "", "", "ISSINK_YES")
# Process: Flow Direction
arcpy.FlowDirection_archydrotools(fill, Fdr, "")
# Process: Flow Accumulation
arcpy.FlowAccumulation_archydrotools(Fdr, Fac)

any idea ?

3

From what I understand, you just have to assign fill, Fdr and Fac the name you want to name those raster! They will be automatically saved to the arcpy.env.workspace.

import arcpy

arcpy.ImportToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Arc Hydro Tools.tbx", "archydrotools")

#Set Ouput Names
fill=arcpy.GetParameterAsText(0) + '\\OuputFillRasterName'
Fdr=arcpy.GetParameterAsText(0) + '\\OuputFdrRasterName'
Fac=arcpy.GetParameterAsText(0) + '\\OuputFacRasterName'

# Local variables:
arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
arcpy.env.workspace = arcpy.GetParameterAsText(0)
cl = arcpy.GetParameterAsText(1)
# Process: Fill Sinks
arcpy.FillSinks_archydrotools(cl, fill, "", "", "ISSINK_YES")
# Process: Flow Direction
arcpy.FlowDirection_archydrotools(fill, Fdr, "")
# Process: Flow Accumulation
arcpy.FlowAccumulation_archydrotools(Fdr, Fac)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.