Hello, I have been using the code below with success with ESRI ArcMap 9.2. However, I'd like to know how to add some more automation to this script. Currently I run this from the command line like this:
C:\Python24\python "C:\Documents and Settings\user\Desktop\test.py" LANDCOVERfileLIST DONUTfileLIST
So each time I want to run this I need to create a list of files to use and then enter their location in the statement above and run. I also change the 'new_name' field each time in the body of the script. I need the count appended to the end to be the way it is, it currently matches the ID of the files. I have six (and counting) sets of landcover files each in their own folder and each with a unique name and numbered 1 - 71 and then I have one set of Donut files each numbered 1 -71. So in the end I'll have 6 sets of files now named new_name01, newname02, etc. How can I set this up to be more automatic?
-make so I just use the folders where the files are located and have a name derived from folder name?
-make a long list with file locations and somehow have the outnames change for every set and the numbers stay in sync?
-do this someother way that is more elegant than I currently think of?
I appreciate annotated code and instructions so that I can learn more about python, etc.
# Runs an expression built with the Map Algebra language.
# Requirements: None
import sys, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
f = open(sys.argv,'r')
circlefile = open(sys.argv,'r')
count = 1
tmpdir = 'c:\\temp\\'
for landcover in f:
donut = circlefile.readline()
# Set local variables
Outfname = os.path.join(tmpdir, 'new_name', str(count))
InExpression = "CON(ISNULL(" + donut.strip() + ")," + landcover.strip() + "," + landcover.strip() + " * -1)"
# Check out Spatial Analyst extension license
# Process: MapAlgebra
count = count + 1
# If an error occurred while running a tool, then print the messages.