Select to view content in your preferred language

Angle between two points

7833
4
Jump to solution
08-25-2015 07:06 AM
mikeharol1
New Contributor II

What is best way to determine angle between two mappoints?

0 Kudos
1 Solution

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

0 Kudos
4 Replies
ThomasEmge
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

0 Kudos
JoeBorgione
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....
mikeharol1
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?

0 Kudos
mikeharol1
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;