# Calculating the inner angle

I have some polygons and I want to calculate the inner angle of each polygon. Now, I have the geometry of every line of polygons in the same attribute table as shown in the following image.

I want to calculate the inner angle using the following equation:

inner_angle= the bearing angle of the previous line - the bearing angle of the following line +180 (in degrees).

How can I write this in the code block in the model builder and do this for each polygon respectively?

I just need code execute that :

( Can the iterate feature in model builder do this loop ( for each polygon)?)

``````for each polygon

for i = 1: last line in the polygon

if i < the last line in the polygon

**angle = the line bearing @ i - the line bearing @ (i+1) +180**

if angle >360

angle= angle -360

end

if angle < 0

angle = angle +360

end
else
angle =   the line bearing @ i - the line bearing @ first line

if angle >360

angle= angle -360

end

if angle < 0

angle = angle +360

end
end

end
``````

The desired result as follows:

## 1 Answer

I don't think, that you need a Python script or an iteration.

You can calculate the interior angle of a polygon using this formula: `(n-2) × 180°`, where `n` is the number of sides.

That makes it possible to solve your problem in two steps:

1. Take the Dissolve-Tool to dissolve the line Feature Class by using the Polygon #ID as the dissolve field and as the statistic field (statistic_type = COUNT) to calculate the number of sides. Now you have the number of sides for each polygon.
2. Use the Calculate Field Tool to calculate the interior angle of the polygon with the formula shown above.

Both Tools can be easily insert in to your ArcGIS Model.

• This answer is a nice one for the sum of angles. But the formula from the question suggests that the interior angle at each vertex is meant. – Matte Dec 12 '17 at 16:08