0

I want to make my field buff_dist longer than by 400ft. I want to write a code that will go through the table and change the field value by adding 400ft to it's value.

How would I write that?

I tried to use UpdateCursor, but I don't think I was understanding it. I also want to be able to select certain objects to change the buff_dist field of, but knowing how to change the field value is one step closer for me!

closed as off-topic by PolyGeo Mar 3 at 12:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

2

Using Field Calculator (simple):

arcpy.CalculateField_management("Buffer_Field","!Buffer_Field!+400","PYTHON_9.3")

Or in ArcMap by opening the attribute table, right click on the Buffer_Field and then in the dialog enter Buffer_Field + 400.

Using update cursor (somewhat advanced):

import arcpy

InTable = "c:\\path\\to\\table" # or feature class

with arcpy.da.UpdateCursor(InTable,["Buffer_Field"]) as UpCur:
    for row in UpCur:
        row[0] = row[0] + 400
        UpCur.updateRow(row)

Note: this is bare bones code with no error checking for Null values or string field types, that gets a little more advanced.

Not the answer you're looking for? Browse other questions tagged or ask your own question.