Here's one method I put together for this. I'm not sure if there's a built in method in arcpy's Geometry object to get bearing or not. In my case, I pulled all the coordinates out of the geometry object into a list. Then iterated through the list, using a little trigonometry to get the bearings.My formulate was adapted from here:http://www.movable-type.co.uk/scripts/latlong.htmldef getBearing(latFrom,lonFrom,latDest,lonDest):
# Returns the initial bearing in degrees from north following the great
# circle path to the destination coordinates.
lat1 = math.radians(float(latFrom))
lat2 = math.radians(float(latDest))
dLon = math.radians(float(lonDest)-float(lonFrom))
y = math.sin(dLon) * math.cos(lat2)
x = math.cos(lat1) * math.sin(lat2) - \
math.sin(lat1) * math.cos(lat2) * math.cos(dLon)
brng = math.atan2(y, x)
return (math.degrees(brng) + 360) % 360;
line_coordinates = []
# Get your geometry object
geoms = [row[0] for row in arcpy.da.SearchCursor(yourFeature_Class,["SHAPE@"])]
# Iterate through all the points in your geomtry, appending them to the "line_coordinates" list
for geom in geoms:
partCount = geom.partCount
for n in xrange(partCount):
part = geom.getPart(n)
for point in part:
line_coordinates.append((point.Y, point.X))
# Iterate through the "line_coordinates" list, printing the bearings
n = 1
while n < len(line_coordinates):
print "%0.4f" % getBearing(line_coordinates[n-1][0],line_coordinates[n-1][1],line_coordinates[0],line_coordinates[1])
n += 1
This method may be a little roundabout, but it's gotten it done for me in the past. Worth noting though, that the bearing is from the starting coordinate, as bearing may change along a longer great circle.