Angle between two points

4107
4
Jump to solution
08-25-2015 07:06 AM
Highlighted
New Contributor

What is best way to determine angle between two mappoints?

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Contributor

There are probably a number of approaches. I suggest using a LineBuilder to create a LineSegment using the two points as the start and the end point. The created segment in return contains an angle property.

https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic7741.html

View solution in original post

Reply
0 Kudos
4 Replies
Highlighted
Esri Contributor

There are probably a number of approaches. I suggest using a LineBuilder to create a LineSegment using the two points as the start and the end point. The created segment in return contains an angle property.

https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic7741.html

View solution in original post

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Alternatively, you may take a look at the Near Tool as well as the Generate Near Table Tool. Each allow you to generate the angle.

Reply
0 Kudos
Highlighted
New Contributor

so i think like the linesegment approach but it returns the angle relative to x axis going counter clockwise as opposed to the preferable gis coordinate system starting at y axis in a clockwise direction.  so if the lineSegment.angle returns 30 degrees that would actually be 60 degrees on the compass.   Is there a method or technique to make the conversion?

Reply
0 Kudos
Highlighted
New Contributor

this seems to work for me thanks for help

double Rad2Degrees = 180 / Math.PI;

var lineBuilder = new LineBuilder(p1, p2);

var lineSeg = lineBuilder.ToSegment();

var degrees = lineSeg.Angle * Rad2Degrees;

degrees = 90 - degrees;

if (degrees < 0)

    degrees = degrees + 360;

Reply
0 Kudos