Converting azimuth from degrees to radians using Field Calculator; only zeros show up.

949
16
Jump to solution
10-02-2018 10:11 PM
Highlighted
New Contributor II

I am attempting to convert the azimuth field in a shapefile from degrees to radians using the Field Calculator, but after providing the equation, all the attributes in the new field show up as zero. Equation is [azimuth]*(pi/180). I also tried the calculation using the approximate decimal value of pi/180 and got the same result.

Attached are screenshots of the dialogue window and the problem with the zeros in the attribute table.

Is there a way to fix this without having to use Python or R, and if so how?

Any help would be greatly appreciated!

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

try the python parser  You get access to the math functions

!azim! is the name of an azimuth field in a table

math.radians(!azim!)

!azim!*math.pi/180

View solution in original post

16 Replies
Highlighted
MVP Esteemed Contributor

try the python parser  You get access to the math functions

!azim! is the name of an azimuth field in a table

math.radians(!azim!)

!azim!*math.pi/180

View solution in original post

Highlighted
New Contributor II

I tried that code using the Python parser and got an error that said: "There was a failure during processing. Please check the Geoprocessing window for details." I received Error 000539: Invalid field azim.

I tried again using my field's name, azimuth, in place of azim, and got the same dialogue but with Error 000539: SyntaxError: invalid syntax, (<expression>, line 2). Should there be another pair of parentheses somewhere, perhaps around pi/180?

The only two results I have gotten in all my attempts so far to convert azimuth to radians are either all zeros or this kind of error.

Thanks for your help! Any other suggestions are greatly appreciated.

Best,

Rachel DiPietro

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

why don't you screen the table and your field calculator expression.

it would be easier than working with textual descriptions

Reply
0 Kudos
Highlighted
New Contributor II

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

you use one or the other in the calculation expression... not both

math.radians(45) == 45*math.pi/180.

True

Reply
0 Kudos
Highlighted
New Contributor II

Okay, my mistake. Here's the new result.

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

is the field a 'Double' type or is it 'Long' or 'Short'

Reply
0 Kudos
Highlighted
New Contributor II

It is a 'Short' type.

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

It should be Double if you want to see decimal points in your numbers... short and long are integers

Reply
0 Kudos