Here is the script, I have bolded the line that is returning the error:# Import modules
import arcgisscripting
import datetime
# Create geoprocessor object
gp = arcgisscripting.create(9.3)
# Get Parameters
catchments = gp.GetParameterAsText(0) # Feature Class
idField = gp.GetParameterAsText(1) # Field
streams = gp.GetParameterAsText(2) # Feature Class
bufferDistance = int(gp.GetParameterAsText(3)) # Long
landCover = gp.GetParameterAsText(4) # Feature Class
outFolder = gp.GetParameterAsText (5) # Workspace
tempWorkspace = gp.GetParameterAsText (6) # Workspace
gp.overwriteoutput = True
gp.Workspace = tempWorkspace
gp.ScratchWorkspace = tempWorkspace
# Set-up environment variables
desc = gp.describe (catchments)
xmin = desc.extent.xmin
ymin = desc.extent.ymin
xmax = desc.extent.xmax
ymax = desc.extent.ymax
gp.XYDomain = str(xmin - (bufferDistance*2)) + " " + str(ymin - (bufferDistance*2)) + " " + str(xmax + (bufferDistance*2)) + " " + str(ymax + (bufferDistance*2))
# Create names for geoprocessing interim files based on the type of workspace selected
wsDesc = gp.Describe(tempWorkspace)
wsType = wsDesc.WorkspaceType
# If the workspace is a folder
if wsType == "FileSystem":
## Interim files must have the ".shp" extension
streamsd = "streamsd.shp"
catchStrm = "CatchStrm.shp"
catchStrmBuff = "CatchStrmBuff.shp"
catchStrmBuffDiss = "CatchStrmBuffDiss.shp"
catchStrmBuffInt = "CatchStrmBuffInt.shp"
selection = "Selection.shp"
selectionDiss = "SelectionDiss.shp"
selectionDissInt = "SelectionDissInt.shp"
tableName = "Rip" + str(bufferDistance) + ".shp"
appendTable = "AppendMe.dbf"
# If the workspace is a geodatabase
elif wsType == "LocalDatabase":
## Interim files do not require an extension
streamsd = "streamsd"
catchStrm = "CatchStrm"
catchStrmBuff = "CatchStrmBuff"
catchStrmBuffDiss = "CatchStrmBuffDiss"
catchStrmBuffInt = "CatchStrmBuffInt"
selection = "Selection"
selectionDiss = "SelectionDiss"
selectionDissInt = "SelectionDissInt"
tableName = "Rip" + str(bufferDistance)
appendTable = "AppendMe"
# Dissolve streams not allowing multipart to reduce the number of features to be buffered
gp.Dissolve_management (streams, streamsd, "", "", "SINGLE_PART", "")
# Count the total number of catchments
resultCatchments = gp.GetCount_management(catchments)
countCatchments = int(resultCatchments.GetOutput(0))
# Make a feature layer from the catchments
gp.MakeFeatureLayer_management (catchments, "CatchLayer")
# Create a search cursor to loop through the catchments 300 at a time
rows = gp.SearchCursor (catchments)
row = rows.next()
x = 0
list = []
while x < countCatchments:
## If there are fewer than 300 features remaining
if countCatchments - x <300:
remaining = countCatchments - x
for i in range (0,remaining,1):
objectID = row.getvalue ("ObjectID")
row = rows.next()
x = x+1
## Otherwise
else:
for i in range (0,300,1):
objectID = row.getvalue("ObjectID")
row = rows.next()
x = x+1
## Add the 300th, or last, ObjectID to the List
list.append (objectID)
# Get the ObjectIDs from the list and perform selections and geoprocessing
# How many items are in the list?
items = len(list)
for i in range (0, items, 1):
## If this is the first item on the list
if i == 0:
query = '"OBJECTID" <= ' + str(list)
lastitem = list
## Otherwise
else:
query = '"OBJECTID" > ' + str(lastitem) + ' AND "OBJECTID" <= ' + str(list)
lastitem = list
gp.SelectLayerbyAttribute_management("CatchLayer", "NEW_SELECTION", query)
## Get the number of catchments selected
resultSelCatch = gp.GetCount_management("CatchLayer")
countSelCatch = int(resultSelCatch.GetOutput(0))
## Intersect catchments and streams
gp.Intersect_analysis ("CatchLayer;" + streamsd, catchStrm, "ALL", "", "INPUT")
resultIntersect = gp.GetCount_management(catchStrm)
countIntersect = int(resultIntersect.GetOutput(0))
## Buffer intersected catchments and streams
gp.RepairGeometry_management (catchStrm)
gp.Buffer_analysis (catchStrm, catchStrmBuff, bufferDistance, "FULL", "ROUND", "NONE")
## Dissolve the buffered streams... process may fail if this is done as part of the buffer operation
gp.Dissolve_management (catchStrmBuff, catchStrmBuffDiss, idField, "", "MULTI_PART", "")
## Intersect catchments and buffer
gp.Intersect_analysis (catchments + ";" + catchStrmBuffDiss, catchStrmBuffInt, "ALL", "", "INPUT")
## Select features where buffer ID and catchment ID are the same
gp.Select_analysis (catchStrmBuffInt, selection, '"'+ idField + '"="' + idField + '_1"')
## Dissolve selected features based on ID, allowing multipart
gp.Dissolve_management (selection, selectionDiss, idField, "", "MULTI_PART", "")
## Intersect dissolved features and land cover
gp.Intersect_analysis (selectionDiss + ";" + landCover, selectionDissInt, "ALL", "", "INPUT")
## Dissolve intersected features based on ID and land cover type, allowing multipart
gp.Dissolve_management (selectionDissInt, tableName, idField + "; SCO_Class", "", "MULTI_PART", "")
## Add field (Area)
gp.AddField_Management (tableName, "Area", "DOUBLE", "#", "#", "#", "", "#", "#", "")
## Calculate area field
gp.CalculateField_management (tableName, "Area", "!" + gp.describe(tableName).shapefieldname + ".AREA@SQUAREMETERS!", "PYTHON_9.3", "")
## If this is the first set
if i == 0:
### Export attribute table
gp.TableToDBASE_conversion (tableName, outFolder)
## Otherwise
else:
### Export the attribute table and append it onto the existing one
gp.MakeTableView_management (tableName, "RipView")
gp.CopyRows_management ("RipView", appendTable)
gp.Append_management (appendTable, outFolder + "\Rip" + str(bufferDistance) + ".dbf", "NO_TEST")
# Delete the Temporary Files
gp.Delete_management (catchStrm)
gp.Delete_management (catchStrmBuff)
gp.Delete_management (catchStrmBuffInt)
gp.Delete_management (tableName)
gp.Delete_management (selection)
gp.Delete_management (selectionDiss)
#gp.Delete_management (selectionDissInt)
gp.Delete_management (streamsd)
gp.Delete_management (catchStrmBuffDiss)
gp.Delete_management (appendTable)
Thanks