Hi,
May i know how can i get a azimuth value between 2 points?
HI Nicholas Furness
I get below error, did you know how to settle this issues?
System.InvalidOperationException HResult=0x80131509 Message=Invalid id for creating a unit Source=Esri.ArcGISRuntime StackTrace: at Esri.ArcGISRuntime.Geometry.Unit.FromUnitId(Int32 unitId) at Esri.ArcGISRuntime.Geometry.LinearUnits.get_Meters() at ArcGISControl.MainWindow..ctor() in C:\Users\mfathin.CSYSINT\Documents\Visual Studio 2017\Projects\ArcGISControl\ArcGISControl\MainWindow.xaml.cs:line 32Inner Exception 1:DllNotFoundException: Unable to load DLL 'RuntimeCoreNet.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
System.InvalidOperationException HResult=0x80131509 Message=Invalid id for creating a unit Source=Esri.ArcGISRuntime StackTrace: at Esri.ArcGISRuntime.Geometry.Unit.FromUnitId(Int32 unitId) at Esri.ArcGISRuntime.Geometry.LinearUnits.get_Meters() at ArcGISControl.MainWindow..ctor() in C:\Users\mfathin.CSYSINT\Documents\Visual Studio 2017\Projects\ArcGISControl\ArcGISControl\MainWindow.xaml.cs:line 32
Inner Exception 1:DllNotFoundException: Unable to load DLL 'RuntimeCoreNet.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
This my code:
private readonly LinearUnit _metersUnit = LinearUnits.Meters; private readonly AngularUnit _degreesUnit = AngularUnits.Degrees;private void CreatePoints() { // Create a red circle simple marker symbol SimpleMarkerSymbol redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00, 0x00), 10);MapPoint mapPoint1 = new MapPoint(-2.72, 56.065, SpatialReferences.Wgs84);MapPoint mapPoint2 = new MapPoint(-2.69, 56.065, SpatialReferences.Wgs84);// Create graphics and add them to graphics overlay graphic1 = new Graphic(mapPoint1, redCircleSymbol); _overlay.Graphics.Add(graphic1);graphic2 = new Graphic(mapPoint2, redCircleSymbol); _overlay.Graphics.Add(graphic2);//CreateLinePoint(); GeodeticDistanceResult distance = GeometryEngine.DistanceGeodetic(mapPoint1, mapPoint2, _metersUnit, _degreesUnit, GeodeticCurveType.Geodesic);textBox.Text = string.Format("Distance:{0} | Azimuth:{1}", _metersUnit.UnitType.ToString(), _degreesUnit.UnitType.ToString());
private readonly LinearUnit _metersUnit = LinearUnits.Meters; private readonly AngularUnit _degreesUnit = AngularUnits.Degrees;
private void CreatePoints() { // Create a red circle simple marker symbol SimpleMarkerSymbol redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00, 0x00), 10);
MapPoint mapPoint1 = new MapPoint(-2.72, 56.065, SpatialReferences.Wgs84);
MapPoint mapPoint2 = new MapPoint(-2.69, 56.065, SpatialReferences.Wgs84);
// Create graphics and add them to graphics overlay graphic1 = new Graphic(mapPoint1, redCircleSymbol); _overlay.Graphics.Add(graphic1);
graphic2 = new Graphic(mapPoint2, redCircleSymbol); _overlay.Graphics.Add(graphic2);
//CreateLinePoint();
GeodeticDistanceResult distance = GeometryEngine.DistanceGeodetic(mapPoint1, mapPoint2, _metersUnit, _degreesUnit, GeodeticCurveType.Geodesic);
textBox.Text = string.Format("Distance:{0} | Azimuth:{1}", _metersUnit.UnitType.ToString(), _degreesUnit.UnitType.ToString());
Hi Mohamad Fathin,
You could set them up something like this:
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">readonly</SPAN> LinearUnit _metersUnit <SPAN class="operator token">=</SPAN> LinearUnits<SPAN class="punctuation token">.</SPAN>Meters<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">readonly</SPAN> AngularUnit _degreesUnit <SPAN class="operator token">=</SPAN> AngularUnits<SPAN class="punctuation token">.</SPAN>Degrees<SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
or just call DistanceGeodetic like this:
GeodeticDistanceResult distance <SPAN class="operator token">=</SPAN> GeometryEngine<SPAN class="punctuation token">.</SPAN><SPAN class="token function">DistanceGeodetic</SPAN><SPAN class="punctuation token">(</SPAN>mapPoint1<SPAN class="punctuation token">,</SPAN> mapPoint2<SPAN class="punctuation token">,</SPAN> LinearUnits<SPAN class="punctuation token">.</SPAN>Meters<SPAN class="punctuation token">,</SPAN> AngularUnits<SPAN class="punctuation token">.</SPAN>Degrees<SPAN class="punctuation token">,</SPAN> GeodeticCurveType<SPAN class="punctuation token">.</SPAN>Geodesic<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
See LinearUnits and AngularUnits.
Hope that helps!
Nick.
Hi
I try using the method for calculate to get the azimuth between 2 point, but i am not understand these two functions:
private readonly LinearUnit _metersUnit; private readonly AngularUnit _degreesUnit;
below is the code i try to implement, sorry i am new to c#
private void CreatePoints() { // Create a red circle simple marker symbol SimpleMarkerSymbol redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00, 0x00), 10);MapPoint mapPoint1 = new MapPoint(-2.72, 56.065, SpatialReferences.Wgs84);MapPoint mapPoint2 = new MapPoint(-2.69, 56.065, SpatialReferences.Wgs84);// Create graphics and add them to graphics overlay Graphic graphic = new Graphic(mapPoint1, redCircleSymbol); _overlay.Graphics.Add(graphic);graphic = new Graphic(mapPoint2, redCircleSymbol); _overlay.Graphics.Add(graphic);GeodeticDistanceResult distance = GeometryEngine.DistanceGeodetic(mapPoint1, mapPoint2, _metersUnit, _degreesUnit, GeodeticCurveType.Geodesic);}
// Create graphics and add them to graphics overlay Graphic graphic = new Graphic(mapPoint1, redCircleSymbol); _overlay.Graphics.Add(graphic);
graphic = new Graphic(mapPoint2, redCircleSymbol); _overlay.Graphics.Add(graphic);
}
Use the GeometryEngine.DistanceGeodetic method. The result, a GeodeticDistanceResult, includes the azimuths between the two points.
Calculating a bearing distance—Help | ArcGIS Desktop
How to Calculate Azimuth in Excel | It Still Works
Now if you can script in Excel this is a custom function I use for determining Azimuths..
I use it in excel like this... =Azimuth(cell with Latitude1, cell with Longitude1, cell with Latitude1, cell with Longitude2)
eg. =Azimuth(A1,B1,A2,B2)
Function <SPAN class="token function">Azimuth</SPAN><SPAN class="punctuation token">(</SPAN>lat1 As Single<SPAN class="punctuation token">,</SPAN> lat2 As Single<SPAN class="punctuation token">,</SPAN> lon1 As Single<SPAN class="punctuation token">,</SPAN> lon2 As Single<SPAN class="punctuation token">)</SPAN> As Single Dim X1 As Single<SPAN class="punctuation token">,</SPAN> X2 As Single<SPAN class="punctuation token">,</SPAN> Y As Single<SPAN class="punctuation token">,</SPAN> dX As Single<SPAN class="punctuation token">,</SPAN> dY As Single With Application<SPAN class="punctuation token">.</SPAN>WorksheetFunction X1 <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="token function">Radians</SPAN><SPAN class="punctuation token">(</SPAN>lat1<SPAN class="punctuation token">)</SPAN> X2 <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="token function">Radians</SPAN><SPAN class="punctuation token">(</SPAN>lat2<SPAN class="punctuation token">)</SPAN> Y <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="token function">Radians</SPAN><SPAN class="punctuation token">(</SPAN>lon2 <SPAN class="operator token">-</SPAN> lon1<SPAN class="punctuation token">)</SPAN> End With dX <SPAN class="operator token">=</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Cos</SPAN><SPAN class="punctuation token">(</SPAN>X1<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Sin</SPAN><SPAN class="punctuation token">(</SPAN>X2<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Sin</SPAN><SPAN class="punctuation token">(</SPAN>X1<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Cos</SPAN><SPAN class="punctuation token">(</SPAN>X2<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Cos</SPAN><SPAN class="punctuation token">(</SPAN>Y<SPAN class="punctuation token">)</SPAN> dY <SPAN class="operator token">=</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Cos</SPAN><SPAN class="punctuation token">(</SPAN>X2<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Sin</SPAN><SPAN class="punctuation token">(</SPAN>Y<SPAN class="punctuation token">)</SPAN> With Application<SPAN class="punctuation token">.</SPAN>WorksheetFunction Azimuth <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="token function">Degrees</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Atan2</SPAN><SPAN class="punctuation token">(</SPAN>dX<SPAN class="punctuation token">,</SPAN> dY<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> End With End Function<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.