Created
November 30, 2017 21:31
-
-
Save pyRobShrk/096f1189bca448268fa2b48e97335bbc to your computer and use it in GitHub Desktop.
ArcMap Field Calculator - Reverse Line Azimuth Angle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script is used to calculate the segment angle for CE-QUAL-W2 | |
# My segment streamline was drawn going downstream | |
# The CE-QUAL input wants radians east of north (CW), pointing upstream | |
# atan2 results are north of east (CCW), the sign change makes it CW | |
# adding pi/2 gives the reverse azimuth, subtracting would be azimuth | |
# In ArcMap Field Calculator using Python Parser: | |
# Pre-Logic Script Code: | |
def reverseAzimuth(shp): | |
a = -math.atan2(shp.firstPoint.Y - shp.lastPoint.Y, shp.firstPoint.X - shp.lastPoint.X) + math.pi/2 | |
if a < 0: | |
return a + math.pi*2 | |
else: | |
return a | |
# field = | |
reverseAzimuth (!Shape!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment