I have a double field with bearings/azimuths (numbers) and I need them in letter directions: N, NE, NW,etc. I would like to calculate them in a new field. I have searched high and low for the code to use in the field calculator but I have failed to figure it out.
Thanks,
Bob
Solved! Go to Solution.
FYI I haven't accounted for changes in the polar axis since this thread was begun
Better get on it
Sent from my iPhone
Dan,
the field I was using your script in was a text field but it still failed to execute. One of the error messages in the Geoprocessing results is "The field is not nullable. [dir] ". Is that the problem?
dir is the field I was working on, Bearing is the field with the angles
Thanks a million,
Bob
you didn't switch to the python parser did you
number is selected as the field type instead of
A small but important fact... your 'bearings' appear to go from -180 to 180 instead of 0-360 as expected by the code. I think the angles are relative to the X axis and not compass bearings. This will have to be fixed on your end.
I could fix the code to do this but it would go from a simple expression expecting a specific input to one that accommodates all possible variants of angle types.
Dan,
The script on *https://community.esri.com/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator
<https://community.esri.com/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator>*
returns angles between successive points, is there a script anywhere that
returns bearings or azimuths? Do any of the other suggested scripts I
received a couple weeks ago return azimuths or bearings between successive
points? Once I have bearings I can then use the *Convert Azimuth to
Compass Bearing *script.
Thanks,
Bob
the first link contains the angle code for successive points and ... a variant of the code that I have posted in several incarnations in this thread... I just wanted to consolidate the field calculator geometry 'stuff' in one place as I think of it.
I am using the following script in ArcGIS 10.3 to calculate Quadrant (in the format angle/NE/SE/SW/NW) from azimuth. See example in:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
def quadrant(NorthAzimuth):
if ((NorthAzimuth>=0) & (NorthAzimuth<90)):
quad = 'N '+str(NorthAzimuth)+' E'
elif ((NorthAzimuth>=90) & (NorthAzimuth<180)):
quad = 'S '+str(180-NorthAzimuth)+' E'
elif ((NorthAzimuth>=180) & (NorthAzimuth<270)):
quad = 'S '+str(NorthAzimuth-180)+' W'
else:
quad = 'N '+str(360-NorthAzimuth)+' W'
return quad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The box Show Codeblock is cheked. This script is copied in the box Pre-logic Script Code. In the box below - "Quadrant = " is typed quadrant (!NorthAzimuth!).
My polyline shape file contains the followings fields: Start_X (double), Start_Y (double), End_X (double), End_Y (Double), Compriment (double) - polyline lenght, and NorthAzimu (double) - azimuth in degrees.
I already replace the term NorthAzimuth of script with NorthAzimu, but without sucess.
The script always returns an error message.
Please, where is the error?