AnsweredAssumed Answered

calculate geometry values for specific fc type

Question asked by jwolff on May 12, 2016
Latest reply on May 13, 2016 by xander_bakker

Wasn't sure how to name this post...

 

I have a geodatabase with multiple feature datasets, each containing multiple feature classes of various polygon, line and point geometry type.  Every polygon fc has a 'areaSize' field that I need to populate with square feet (all of the fds are in State Plane feet).

I think I'm getting close here, but still getting an error.  (Eventually I will expand this to perform a similar calculation for length of line fc types as well.

The error I receive is attached.  Any help is greatly appreciated.

Thanks.

#*********************************
#v1.0
#*********************************
import arcpy
from arcpy import env
import os

#Set variables
inputgdb = sys.argv[1]

#Set workspace
arcpy.env.workspace = inputgdb

#populate areaSize fields in polygon feature classes
datasetList = arcpy.ListDatasets(feature_type = 'feature')
datasetList = [''] + datasetList if datasetList is not None else []
print "Getting Feature Datasets..."
arcpy.AddMessage ("Getting Feature Datasets...")
print datasetList
arcpy.AddMessage (datasetList)

for dataset in datasetList:
    env.workspace = inputgdb + "\\" + dataset
    dataset = dataset + "\\"
    fcList = arcpy.ListFeatureClasses('*', 'polygon', '*')
    print "Getting Feature Classes..."
    arcpy.AddMessage ("Getting Feature Classes...")
    print "Feature Class list..."
    arcpy.AddMessage (fcList)
    
    for fc in fcList:
        fc = fc +"\\"
        fieldList = [f.name for f in arcpy.ListFields(fc, "areaSize")]
        with arcpy.da.UpdateCursor (fc, fieldList) as cursor:
            for row in cursor:
                row[1] = row[0].area
                cursor.updateRow(row)
                print "Updating 'areaSize' field in: " + fc
                arcpy.AddMessage ("Updating 'areaSize' field in: " + fc)

Attachments

Outcomes