Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am looking for a Python code block to calculate azimuth per each polyline feature. So far I have been able to use the following Python code to calculate bearing:

180  + math.atan2(( !Shape.firstpoint.X! - !Shape.lastpoint.X! ),
(!Shape.firstpoint.Y! - !Shape.lastpoint.Y! ) ) * (180 / math.pi)

However bearing is not sufficient for me as I am looking to ultimately find line directions which can be detected by caclulating an azimuth.

share|improve this question
add comment

1 Answer

Not in arcpy but the math is pretty clear. From Bill Huber in 2004.

How do I compute azimuth for line segment and add to attribute table

z = (-y/x).ATan.AsDegrees
if (x < 0) then z = z+180 end ' Adjust ATan in quadrants II and III
z = -(z + 180 mod 360 - 180)  ' Convert to the range -180..180
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.