2

I have a list of values of buildings total height and want to update the corresponding field in the shapefile.

fclass is my shapefile totalh is the field which i want to update totaheight is a list with height values for each building in the shapefile (same order)

This is what I am trying:

i = 0
with arcpy.da.UpdateCursor(fclass,"totalh") as updatecursor:
 for row in updatecursor:
 row[i] = total_height[i]
 updatecursor.UpdateRow(row)
 i = i+1

The error:

Traceback (most recent call last):
 File "C:/wspace2/bheights.py", line 45, in <module>
 updatecursor.UpdateRow(row)
AttributeError: 'da.UpdateCursor' object has no attribute 'UpdateRow'
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jun 2, 2016 at 18:36
1
  • 1
    row[n] refers to column 'n' in the row, so you're about to have a problem once you fix the capitalization. Commented Jun 2, 2016 at 18:52

1 Answer 1

8

Change

updatecursor.UpdateRow(row) 

to

updatecursor.updateRow(row)

The U is lowercase.

http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/updatecursor-class.htm

Also, check the following statement:

row[i] = total_height[i]

this should probably be

row[0] = total_height[i]

since you want to reference and update the first attribute in the shape file

John Powell
13.7k5 gold badges49 silver badges62 bronze badges
answered Jun 2, 2016 at 18:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.