I have a feature class whose attribute table looks like this:

Latitude | Longitude | Area

For the area column, all rows are null. I would like to put in a specific value for all rows using Python.

I know how to do this on the front-end in the ArcMaps application ( right click > Open Attribute Table > right click on column > field calculator > input value).

How can I accomplish this programmatically using Python?

  • Do you want to calculate the area for each feature? Commented Jun 11, 2014 at 18:49

2 Answers 2


You can calculate the values for a column with Python by using either a GP tool Calculate Field or arcpy UpdateCursor (this one is faster when working with large datasets).

For calculating the geometrical properties of features, you can either use GP tool Add Geometry Attributes or using tokens (such as SHAPE@AREA) of update cursor.

  • 1
    +1 for cursors, specifically the data access module. I don't really use Calculate Field anymore.
    – Paul
    Commented Jun 11, 2014 at 18:55
  • 1
    @Paul, I still do :) sometimes it is just plain easier syntax wise. Of course only for minor datasets. Commented Jun 11, 2014 at 18:58
  • Anything past one or two lines, yes. :)
    – Paul
    Commented Jun 11, 2014 at 18:59

The simplest way, until you are more familiar with the syntax, would be to use the field calculator as you normally do and then go to Geoprocessing -> Results. From there, you can expand Current Session and, right-clicking on the most recent tool that was run, select Copy as Python Snippet.

You'll likely have to change the names of a few inputs, but that should get you started.


Your Answer

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

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