how to get bearing between two point in ArcGIS .Net SDK

765
9
Jump to solution
12-27-2023 07:49 AM
SatyaraySingh
New Contributor II

I'm trying to find the bearing between two points. Even though we have a property as CurrentBearing in stop-class, it shows NaN if you create the object Stop using any MapPoint. For example

var PointA = new MapPoint(-117.85, 32.20, SpatialReferences.Wgs84);

var StopA= new Stop(PointA);

So if we use StopA.CurrentBearing it will show as NaN.

 I just want to find a Bearing value. is there any way I can find the value in .net SDK or do I have to calculate it manually?

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MichaelDavis3
Occasional Contributor III

You want to use the Geometry Engine to do a DistanceGeodesic - this will return the distance as well as the bearing:

https://developers.arcgis.com/net/api-reference/api/net/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Geomet...

View solution in original post

0 Kudos
9 Replies
MichaelDavis3
Occasional Contributor III

You want to use the Geometry Engine to do a DistanceGeodesic - this will return the distance as well as the bearing:

https://developers.arcgis.com/net/api-reference/api/net/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Geomet...

0 Kudos
SatyaraySingh
New Contributor II

Thank You, It works for me.

Just an Addition to it. If I needed to find bearing from True North to a particular Mappoint. is there any method to do so? 

0 Kudos
ShellyGill1
Esri Contributor

If I needed to find bearing from True North to a particular Mappoint. is there any method to do so? 

Hi @MichaelDavis3 - I think that theGetConvergenceAngle method on SpatialReference could be helpful here in figuring out a difference between True North and Grid North for a specific pointhttps://developers.arcgis.com/net/api-reference/api/net/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Geomet...

MichaelDavis3
Occasional Contributor III

This is great - I totally missed that this was added way back at 100.3 and have been using a separate WMM implementation to calculate magnetic declination.  Do you know if this is using the NGS COF data and updated as they release adjustments/updates?

0 Kudos
ShellyGill1
Esri Contributor

Hi @MichaelDavis3 - I'm not sure on the details of the implementation, so I will see if I can get this confirmed for you.

0 Kudos
BojanŠavrič
Esri Contributor

@MichaelDavis3 

GetConvergenceAngle method does not calculate magnetic declination but provides a difference between True North (calculated in GCS) and Grid North (calculated in PCS). The math relies purely on projection’s mathematics, and it does not require a dataset.

SatyaraySingh
New Contributor II

It gives always 0. I'm not sure what I did wrong.

var ConvergenceAngle = SpatialReferences.Wgs84.GetConvergenceAngle(MapPoint)

0 Kudos
ShellyGill1
Esri Contributor

@SatyaraySingh  - if your map point is always WGS84, could this be because WGS84 is always magnetic north aligned anyway? If there's no difference then the method will always return 0. If you use a projected coordinate system that is not magnetic north aligned then I'd expect a non-0 result - for example, if have a point in British National Grid as below (WKID 27700), then I get a result of -0.984136.

var bngPoint = new MapPoint(325847, 674007, SpatialReference.Create(27700));
var ConvergenceAngle = bngPoint.getSpatialReference().getConvergenceAngle(bngPoint);
BojanŠavrič
Esri Contributor

@SatyaraySingh 
Convergence angle is a difference between between True North and Grid North, and its value depends on a map projection used in a grid.

If you use WGS 1984, technically this is not a projected coordinate system, but a geographic coordinate system, so your "grid" north with always be True North, and convergence angle is always 0.

The same results would be in WGS 1984 Web Mercator, because the Mercator projection displays straight meridians and Grid North will always be aligned with True North. This would be the case with any cylindrical projection in normal aspect. 

With other projected coordinate systems, like UTM or State Plane CRS, True and Grid North might be different, so convergence angle will not always be 0 (depending on the location).

I hope this explains it.

0 Kudos