I never used python but now I need a code to do this calculation:
I'm doing this:
math.atan(math.fabs( !Y2! - !Y1!)/math.fabs( !X2! - !X1!) )*(180/math.pi)
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Could you do something like:
Pre-Logic Script code:
def mathFunction(y1, y2, x1, x2): return math.Atan(math.fabs(y2-y1) / math.fabs(x2-x1)) * (180/math.pi)
Field = (on the bottom)...populate with your fields for y1,y2,x1,x2
See Python doc on the math module.
Are you looking for atan2 ? It's precisely meant to deal with this signs mess.