我正在尝试在 arcgis 10 中使用 Python 计算方位角,但出现语法错误。这是我的代码:
def CalculaAzimuth(Linea):
Xorigen = linea.firstPoint.Y
Yorigen = linea.firstPoint.X
Xfinal = linea.lastPoint.X
Yfinal = linea.lastPoint.Y
DeltaX = Xfinal - Xorigen
DeltaY = Yfinal - Xorigen
PI = math.pi()
Azimuth = 4 * PI
if DeltaX = 0:
if DeltaY >=0:
Azimuth = 0
else:
Azimuth = 180
elif DeltaX >0:
Azimuth = 90 - math.atan( DeltaY / DeltaX ) * 180 / PI
elif DeltaX <0:
Azimuth = 270 - math.atan( DeltaY / DeltaX )* 180 / PI
return Azimuth