arctan in field calculator

7615
6
Jump to solution
10-31-2014 02:41 AM
aTomasaLooström
New Contributor

Hello!

I want to calculate the slope of the roof of the house and get the result in degrees. I have the height difference between the highest and lowest points of the roof and the length of the roof in the attribute table. Have tried math.atan () but do not get it to work. I have used field calculator.

Tomas

0 Kudos
1 Solution

Accepted Solutions
ArnoldKuilman
Occasional Contributor

Result is in radians: 0.737815 / PI *180 = 42

Solution is to divide the atan output answer by PI, and multiply by 180.

View solution in original post

6 Replies
DanPatterson_Retired
MVP Emeritus

show the field calculator expression... also, you do have the python parser selected? Did you go to the Results window and check the error message? and if so what was it?

0 Kudos
aTomasaLooström
New Contributor

Hi,

Yes I have the python parser, the expression is:

math.atan(2.5/2.75 )

I get a result but it is wrong or not i degree. The result I get is 0,737815 it should be 42.

0 Kudos
ArnoldKuilman
Occasional Contributor

Result is in radians: 0.737815 / PI *180 = 42

Solution is to divide the atan output answer by PI, and multiply by 180.

aTomasaLooström
New Contributor

Hi,

Thanks a lot!

0 Kudos
DanPatterson_Retired
MVP Emeritus

of course atan doesn't return degrees, it needs to be converted using the math.degree method

>>> import math

>>> math.degrees(math.atan(2.5/2.75))

42.27368900609374

>>>

aTomasaLooström
New Contributor

Thanks a lot, my maths are quite old...

0 Kudos