I have a polygon shapefile and I want to write a Python script to add a field named "area" and calculate its geometry areas.

The script is like this:


When I run it the field adds, and you can see the process of calculating the geometry area.

However, in the attribute table, there are no values in the field "area".

How to solve this problem?

1 Answer 1


Try this instead:


I think you need to use a DOUBLE instead of LONG to get the desired area values. I suspect your "no values" are roundings of floating point numbers to an integer value of 0 - but I cannot be sure.

To get the above syntax I used Copy As Python Snippet from a successful run of each tool using its tool dialog.


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.