Thank-you,Shape.Area worked while I was running the code in pythonwin. I have now imported the code into a toolbox and it is no longer working.In the code below, if tempWorkspace is a geodatabase the code works, if it's a file, then I get an error saying field "LCArea" does not exist within table.Import Modules
import arcgisscripting
# Create Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = True
# Set up parameters
catchmentsFC = gp.GetParameterAsText(0) #in a toolbox GUI, Type = FeatureLayer
landCoverFC = gp.GetParameterAsText(1) #in a toolbox GUI, Type = FeatureLayer
tempWorkspace = gp.GetParameterAsText (2) #in a toolbox GUI, Type = Workspace
tableFolder = gp.GetParameterAsText (3) #in a toolbox GUI, Type = Folder
tableName = gp.GetParameterAsText (4) #in a toolbox GUI, Type = String
tableView = tableFolder + "\\" + tableName
gp.Workspace = tempWorkspace
wsDesc = gp.Describe(tempWorkspace)
wsType = wsDesc.WorkspaceType
if wsType == "FileSystem":
# Intersect land cover and catchments
gp.Intersect_Analysis (catchmentsFC + ";" + landCoverFC, "Intersect.shp", "ALL", "", "INPUT")
# Dissolve output based on catchment and land cover IDs
gp.Dissolve_management ("Intersect.shp", "Dissolve.shp", "UCID; GRIDCODE", "", "MULTI_PART", "")
# Create a table, add and caculate the area
gp.MakeTableView_management("Dissolve.shp", tableView, "", "", "UCID Catchment VISIBLE; GRIDCODE LandCov VISIBLE")
gp.AddField_management (tableView, "LCArea", "DOUBLE", "", "", "", "", "", "", "")
expression = "!SHAPE.AREA@SQUAREMETERS!"
fields = gp.ListFields (tableView)
gp.CalculateField_management (tableView, "LCArea", expression, "PYTHON_9.3", "")
# Export the table to dBASE
gp.TableToDbase_conversion (tableView, tableFolder)
elif wsType == "LocalDatabase":
gp.Intersect_Analysis (catchmentsFC + ";" + landCoverFC, "Intersect", "ALL", "", "INPUT")
# Dissolve output based on catchment and land cover IDs
gp.Dissolve_management ("Intersect", "Dissolve", "UCID; GRIDCODE", "", "MULTI_PART", "")
#desc = gp.Describe("Dissolve")
gp.MakeTableView_management("Dissolve", tableView, "", "", "UCID Catchment VISIBLE; GRIDCODE LandCov VISIBLE; Shape_Area LCArea VISIBLE")
gp.TableToDbase_conversion (tableView, tableFolder)
print 'done'