[GIS] expression for finding perimeter in ArcPy and Field Calculator

arcpyfield-calculator

What is the correct format for finding perimeter as an expression for arcpy.
I was able to use expression !shape.Area! to find the area of my polygon.
However when I use the expression !shape.Perimeter! I get invalid expression.
I've tried the following expressions;

!shape.Perimeter!@KILOMETERS!

!shape.geodesicPerimeter!

!shape.geodesicPerimeter@KILOMETERS!

These do not work. I was able to find the perimeter using the attribute table and right clicking and going to calculate geometry. Therefore I know its possible, just I require the syntax for my python code.

My python code that works for area looks like this.

arcpy.CalculateField_management("Iceberg","Area","!shape.geodesicArea@SQUAREKILOMETERS!","PYTHON_9.3","#")

However my python code for perimeter is not working and it looks like this;

arcpy.CalculateField_management("Iceberg","Area","!shape.geodesicperimeter@KILOMETERS!","PYTHON_9.3","#")

I must be missing something, and I've looked at some examples, and have also done, X and Y coordinates, all work, but I cannot get my perimeter to work 🙁

Best Answer

Try using the word "Length" (i.e. length of polylines, perimeter of polygons) instead of "Perimeter":

arcpy.CalculateField_management("Iceberg","Area","!shape.geodesicLength@KILOMETERS!","PYTHON_9.3","#")

I found the geodesicLength property documented in the Calculate Fields examples page:

Geodesic area and length can also be calculated using geodesicArea and geodesicLength properties with @ followed by a unit of measure keyword.

Related Question