Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I can't seem to find it.

forums.arcgis.com/threads/… –  whuber Oct 22 '10 at 17:05

2 Answers 2

up vote 3 down vote accepted

alt text You mean this? Select, and then tap in angle, as per what u did in 931? Can still do direction/length in combo as well. Let me know if this is not what ur after


This Python script tool will do the trick. To use it, add it as a script tool, set the parameter to Feature Set - and set its schema to a line feature class. This script should work with 10.0 and later.

# calculate an azimuth angle from a interactively entered
# line (feature set)
# Curtis Price, cprice@usgs.gov,  9/18/2013 11:51:10 AM

import math
import arcpy

# read line (This parameter should be a line feature set)
line = arcpy.GetParameterAsText(0)

# to see how this is used, see the help:
# http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000028000000
# http://resources.arcgis.com/en/help/main/10.1/index.html#//002w00000023000000

def get_angle(xy1, xy2):
  """Calculate azimuth angle from two points. (Zero is north.)"""
  import math
    # ArcPy point objects
    x1, y1, x2, y2 = xy1.X, xy1.Y, xy2.X, xy2.Y
    # xy strings, e.g. "0 0"
    x1, y1 = [float(x) for x in xy1.split()]
    x2, y2 = [float(x) for x in xy2.split()]
  dx, dy = (x2 - x1, y2 - y1)
  return 90 - math.degrees(math.atan2(dy, dx))

  # get first and last point of a line
  SHAPE = arcpy.Describe(line).shapeFieldName
  Rows = arcpy.SearchCursor(line,"","",SHAPE)
  feat = Rows.next().getValue(SHAPE)
  pt1 = feat.firstPoint
  pt2 = feat.lastPoint
  angle = get_angle(pt1, pt2)
  msg1 = "  First point: {0:.1f}, {0:.1f}".format(pt1.X, pt1.Y)
  msg2 = "  Last point:  {0:.1f}, {0:.1f}".format(pt2.X, pt2.Y)
  msg3 = "  Azimuth angle (in degrees): {0:.1f}".format(angle)
  arcpy.AddMessage("{0}\n{1}\n{2}".format(msg1, msg2, msg3))
  raise Exception, "Invalid line input"

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .