Select to view content in your preferred language

# Angle between two points

7833
4
08-25-2015 07:06 AM
New Contributor II

What is best way to determine angle between two mappoints?

1 Solution

Accepted Solutions
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

4 Replies
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

MVP Emeritus

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.

That should just about do it....
New Contributor II

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?

New Contributor II

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;