In a file geodatabase table, I have an attribute called 'NEAR_ANGLE' created via the "Generate Near Table" tool that I'd like to convert to a 0-360 degrees format. I've created an attribute called 'Angle_360' in order to store the converted angles. Both these attributes have double as data type.
Regarding the current angle format - I selected the Geodesic method for running the "Generate Near Table" tool, and here's what the tool help states in ArcMap regarding its angle format:
When the Geodesic method is used, the angle is within the range of -180° to 180°, with 0° to the north, 90° to the east, 180° (or -180°) to the south, and -90° to the west.
I tried doing the conversion by using a Python script in "Field Calculator" for the 'Angle_360' attribute, but I've been unsuccessful. I'm an absolute beginner in ArcPy/Python, so I'm pretty sure I have huge syntax errors. Below is what I have so far:
Pre-Logic Script Code:
def Calculate(NearAngle): if ( [NEAR_ANGLE] < 0 and [NEAR_ANGLE] > -180): [NEAR_ANGLE] = [NEAR_ANGLE] +360 return [NEAR_ANGLE] else: return [NEAR_ANGLE]
Error messages are below:
ERROR 000539: Error running expression: Calculate(153.979921739005)
Traceback (most recent call last):
File "< expression >", line `, in < module >
File "< string >", line 2, in Calculate
UnboundLocalError: local variable 'NEAR_ANGLE' referenced before assignment
Failed to execute (CalculateField).
Failed at Sun Apr 22 12:47:12 2018 (Elapsed Time: 0.13 seconds)