It's much harder than that! I frequently want to adjust stripmap angles after they have been created and it is very difficult to calculate the angle of a polygon. COGO tools are no use because they only handle lines. You would have to split the polygons back to lines and then you would still not have a useful angle.I wrote my own Python script and used math.tan2(y/x) to get bearings, that then had to be normalised.You could use the new tool in 10.x Data Management>Features>Maximum Bounding Geometryand set the option "Add geometry" which includes a nice field MBG_orientation suitable to use, but of course it is now in a new featureclass with all your nice attributes trashed, so you would have to make sure you group by SMAP_NUM , join back and recalculate. Still a bit less work that my Python script. But here it is anyway in case it helps you.# UpdateAngle.py
# assumes rectangular polygons
# find bearing of longest side
# might have trouble with up
# 2 June 2011
# Kim Ollivier
import arcgisscripting
from math import *
import datetime
gp = arcgisscripting.create(9.3)
try:
layer = sys.argv[1]
except:
layer = "stripindex"
ws = 'e:/teararoa/nz/current.gdb'
gp.workspace = ws
if not gp.Exists(ws):
print "ws",ws
raise Exception
rotField = "smap_angle"
if not gp.ListFields(layer,rotField):
gp.AddField(layer,rotField,"FLOAT")
def calcbearing(dPt):
'''
calculate bearing of longest side
'''
# points
pt1 = dPt[1]
pt2 = dPt[2]
pt3 = dPt[3]
# lengths
l1 = hypot(pt2[0] - pt1[0],pt2[1] - pt1[1])
l2 = hypot(pt3[0] - pt2[0],pt3[1] - pt2[1])
# bearings
b1 = atan2(pt2[1] - pt1[1],pt2[0] - pt1[0])
b2 = atan2(pt3[1] - pt2[1],pt3[0] - pt2[0])
# print "test",round(l1),round(l2),degrees(b1),degrees(b2)
# print dPt
if l1 > l2 :
degree = degrees(b1)
else:
degree = degrees(b2)
bearing = 90.0 - degree
if bearing > 90:
bearing = bearing - 180
if bearing < -90:
bearing = bearing + 180
return bearing
cur = gp.UpdateCursor(layer) ##,"ID = 1")
row = cur.next()
print
while row:
feat = row.Shape
for partNum in range(feat.partCount) :
part = feat.getPart(partNum)
dPt = {}
n = 0
for pt in iter(lambda: part.next(),None): # stops at null pt
n+=1
dPt = (pt.X,pt.Y)
rotation = calcbearing(dPt)
row.setValue(rotField,rotation)
row.setValue("LastUpdate",datetime.datetime.now())
# print row.objectid,row.id,row.island,rotation #,dPt
cur.updateRow(row)
row = cur.next()
del row,cur
Next the challenge will be to write something that will rotate the feature from the attribute. Numpy will be useful here.