Select to view content in your preferred language

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

6112
16
Jump to solution
10-02-2018 10:11 PM
RachelDiPietro
Emerging Contributor

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!

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

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
DanPatterson_Retired
MVP Emeritus

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

RachelDiPietro
Emerging Contributor

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

0 Kudos
DanPatterson_Retired
MVP Emeritus

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

it would be easier than working with textual descriptions

0 Kudos
RachelDiPietro
Emerging Contributor

0 Kudos
DanPatterson_Retired
MVP Emeritus

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

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

True

0 Kudos
RachelDiPietro
Emerging Contributor

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

0 Kudos
DanPatterson_Retired
MVP Emeritus

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

0 Kudos
RachelDiPietro
Emerging Contributor

It is a 'Short' type.

0 Kudos
DanPatterson_Retired
MVP Emeritus

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

0 Kudos