2

While trying to rotate the end caps of a water network in ArcMap, i calculated the rotation of the connected water main using the field calculator, then did a spatial join to transfer the attribute to the cap and used rotation in symbology to implement the rotation. My problem is as shown in the picture below. The end caps that are left of the watermain are correct but the ones on the right are not. It is quite logical if you consider the angle.

The python code used for the angle calculation is:

Expression:  
GetAzimuthPolyline( !Shape!)  

Code Block:  
import math  
def GetAzimuthPolyline(shape):  
 radian = math.atan((shape.lastpoint.x - shape.firstpoint.x)/(shape.lastpoint.y - shape.firstpoint.y))  
 degrees = radian * 180 / math.pi  
 return degrees  

Is there a better way to do this kind of symbology without being affected by the line direction?

Probably something like "perpendicular to line".

endcap

  • Try doing a geometry check to determine if the end cap is on the start or end of the line. From there you will know if you need to rotate the cap by an additional 180 degrees – Ben S Nadler Oct 12 '16 at 20:19
  • There are thousands of caps. Is there a way to do this automatically? – K.Frantzios Oct 12 '16 at 20:23
  • Yes, using update cursor, select each cap, spatial selection to get line, do the math, figure out if cap is on start or end, get final rotation angle, update field in cap. easy! – Ben S Nadler Oct 12 '16 at 20:28
1

I think the problem lies in the direction that the lines are drawn. To me, it seems that the lines on the right were drawn from right to left. However the lines on the left appear that they should be drawn from left to right. But my guess is that they weren't. Try reversing the line direction and recalculating the angle.

In simplest terms, imagine a horizontal line drawn from left to right. The angle is 0°. However the same line drawn from right to left is 180°.

  • There are too many lines to even check the line direction. I was thinking more of a "perpendicular to line" approach. – K.Frantzios Oct 11 '16 at 11:01
  • 1
    What do you mean, exactly? Please edit your question to explain what you had in mind. – Fezter Oct 11 '16 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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