Select to view content in your preferred language

# Determine the angle between two intersecting lines - Counter-Clockwise direction

6137
3
08-02-2016 09:33 AM
by
Deactivated User

Hey everyone:

I am trying to determine the angle between two intersecting lines. However, I need the angle to be from the start point of line1 to the start- or end-point of line2 - whichever is the next point going in a counter-clockwise direction around the circle's perimeter (see diagram at bottom of question).

My steps so far have been:

1) I found the intersection points and saved them to a point file

2) I created a 10cm buffer around the points (0.1 metres)

3) I clipped line1 and line2 to the buffer

4) I calculated the start- and end-points of line1 and line2 as:

with arcpy.da.UpdateCursor("line", ('X0a','Y0a','X1a','Y1a', "SHAPE@")) as cursor:

for row in cursor:

row[0] = row[4].firstPoint.X

row[1] = row[4].firstPoint.Y

row[2] = row[4].lastPoint.X

row[3] = row[4].lastPoint.Y

cursor.updateRow(row)

5) I created separate fields and calculated their values as:

dx = !X1a!-!X0a!

dy = !Y1a!-!Y0a!

dxa= !X1b!-!X0b!

dya= !Y1b!-!Y0b!

r = math.sqrt(math.pow(!dx!, 2) + math.pow(!dy!, 2))

ra = math.sqrt(math.pow(!dxa!, 2) + math.pow(!dya!, 2))

c = math.asin(abs((dxdya - dydxa))/(r*ra)) / math.pi * 180

c is the angle between the points, however, it is not always the angle I need. I need the angle from a point on line1 to the nearest point on line2 going counter-clockwise around the circle's perimeter.

There is probably a really easy  solution for this, but, I just haven't been able to figure it out. Any help is greatly appreciated.

I am using ArcGIS 10.2.

Tags (1)
3 Replies
MVP Honored Contributor

Forgive me for not wanting to dive back into the tedium of this math, but perhaps you can use something from this thread: Calculating angles using ArcGIS Desktop 10.2

MVP Emeritus

a few points on the image or directional arrows to we know where start and end points are

by
Deactivated User

Thanks for the response Dan,

I have added points on the image to show where the start- or end-points are. The start- and end-points correspond with where the line feature touches the boundary of the polygon circle. However, in the data, the start- and end-points do not follow a particular pattern or direction.

For my purposes, it doesn't matter if I am comparing a start-point of line1 to an end-point of line2. All that matters is that the point of line1 is being compared to the point of line2 that is first encountered going counter-clockwise around the circle's perimeter.

In the Picture in my edited post I would want to compare the two points with the arrow drawn between them.