Skip to main content
added 8 characters in body
Source Link
wittich
  • 2.4k
  • 1
  • 18
  • 31

Additional to Aarons correct answer here the a way to use atan2atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

exampleexample radian

Additional to Aarons correct answer here the a way to use atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

example

Additional to Aarons correct answer here the a way to use atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

example radian

replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

Additional to Aarons correct answerAarons correct answer here the a way to use atan2 as suggested by Mike TMike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

example

Additional to Aarons correct answer here the a way to use atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

example

Additional to Aarons correct answer here the a way to use atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

example

Source Link
wittich
  • 2.4k
  • 1
  • 18
  • 31

Additional to Aarons correct answer here the a way to use atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
  radian = math.atan2(shape.lastpoint.y - shape.firstpoint.y, 
                      shape.lastpoint.x - shape.firstpoint.x)
  radian = radian - (math.pi /2 ) # turn minus 90°
  if (radian > 0):
     degrees = 360 - ( radian  *  360) / ( 2 * math.pi  ) 
  else:
     degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  ) 
  return degrees 

# angle =
GetGeographicalDegrees( !SHAPE! )

screenshot filed calculator

Example:

example