bjschroeder

arcpy.da.UpdateCursor using geometry

Discussion created by bjschroeder on Apr 12, 2013
Latest reply on Apr 12, 2013 by Wayne_Whitley
I am having a difficult time understanding geometry as a concept accessed by the da module.

For example, I created a new feature class using the clip geoprocessing tool. I want to update the "HECTARES" field, as well as add a "Shape_Area" field that is updated with Shape@Area geometry.

arcpy.Clip_analysis(fireLayer,refugeLayer,outLayer)
arcpy.AddField_management(outLayer,"Shape_Area", "DOUBLE")
updateRows = arcpy.da.UpdateCursor\
             (outLayer,["HECTARES","Shape@Area"])

for row in updateRows: #fields --> 0:Hectares, 1:ShapeArea
    HA = row[1]/10000 #Area in hectares
    row[0] = HA #assign value to each row of Hectares
    row[1] = ["Shape@Area"]
    updateRows.updateRow(row) #save it by using the updateRow function
del updateRows # unlock cursor
del row #remove cursor pointer 


This code will update my "HECTARES" field if I comment out the line
    row[1] = ["Shape@Area"]

which leads me to believe that while row[1] remains empty, it still has access to the Shape@Area geometry.

Thanks.

Outcomes