5

This operation is using the Field Calculator in ArcGIS Pro 2.1.

I am trying to calculate the Polsby-Popper Score for Congressional Districts. I have calculated the Geodesic Area and Geodesic Perimeter for each feature using this formula:

(12.56637 * !AREA_GEO!) / (!PERIM_GEO! ^ 2)

It is returning the error:

ERROR 000539: Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for ^: 'float' and 'int'

I am not sure what exactly this error means.

  • what type of field are you making the calculations (e.g. float, integer, text, etc.)? – Aaron Feb 20 '18 at 3:19
  • you want to square !PERIM_GEO!, is that correct? It doesn't like the mixed type, try !PERIM_GEO! * !PERIM_GEO! instead. The value '2' is an integer but !PERIM_GEO! is a float type hence the error message; this operator doesn't do what you think it does in python, it's a bitwise XOR, not an exponent (like C). – Michael Stimson Feb 20 '18 at 3:19
  • We have a self-assembling FAQ on ERROR 000539. – PolyGeo Feb 20 '18 at 4:08
6

As was mentioned in the comments, your formula should read:

(12.56637 * !AREA_GEO!) / (!PERIM_GEO! ** 2)

or

(12.56637 * !AREA_GEO!) / (!PERIM_GEO! * !PERIM_GEO!)

This page on python operators shows that the ^ operator is Bitwise XOR.

  • That worked. Both of the input fields are Doubles and the output field is a float. – SteveC Feb 20 '18 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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