Modify script to loop through all files in directories
Hello,
I think this script would work great if it would cycle through all the rasters in each of these folders and then save a new output raster for each iteration. Currently it justs goes the directory as listed I need it to cycle through all of the directories within my sys.argv[2] and sys.argv[3]
(a raster is directory containing several files that is recognized by ArcMap as a single unit or "file")
donut = sys.argv[2]
lc = sys.argv[3]
Each of these directories contains several other directories that are the input rasters.
I would appreciate help to do this,
Thanks,
MJ
I am new to scripting and I would appreciate any help and annotation.
Thanks,
MJ
# Import system modulesimport sys, string, os, arcgisscripting# Create the Geoprocessor objectgp = arcgisscripting.create()# Check out any necessary licensesgp.CheckOutExtension("spatial")# Load required toolboxes...gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")# Script arguments...outRaster = sys.argv[1]donut = sys.argv[2]lc = sys.argv[3] InExpression = "CON(ISNULL(%s), %s, %s * -1)"%(sys.argv[2],sys.argv[3],sys.argv[3])# Check out Spatial Analyst extension licensegp.CheckOutExtension("Spatial")# Process: MapAlgebragp.SingleOutputMapAlgebra_sa(InExpression, outRaster)