Calculate Distance and Bearing

Calculate Distance and Bearing

Distance is the measure of the space between two points, often measured in kilometres, miles or nautical miles. Bearing is the measure of the direction of one point relative to another, usually measured in degrees.

To calculate the distance between two points, you can use the Haversine formula: a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c

Where lat1, long1, lat2, and long2 are the coordinates of the two points, R is the radius of the Earth (e.g. 6371 km), and d is the distance between the two points.

To calculate the bearing from point A to point B, you can use the following formula: θ = atan2(sin(Δlong).cos(lat2), cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))

Where θ is the bearing in degrees, lat1, long1, lat2, and long2 are the coordinates of the two points.

It’s important to note that the bearing angle is measured clockwise from north.

Note: The formulas are a simplified version; the actual implementation will have some variations based on the requirement and the precision required.

This post explains how to calculate distance and bearing from two points on a map.

Pacific to Araxi Map
Pacific to Araxi Map

Defined

Distance is the point between two locations.

Bearing is the angle measured from the north to the target. North is 0°, East is 90°, South is 180°, and West is 270°.

Tools

One of the easiest methods to calculate distances and bearing is with a software program called TinyLocator. This software is an offline Location converter. See TinyLocator for more details.

Methods

If you are in a situation where you do not have this software, you can use the P2P method described in Tricking Winlink Express to Forecast Your Point-to-Point Contacts.

You can manually calculate distance and bearing using the haversine formula. First, you must convert the Maidenhead grid locator to latitude and longitude. Maidenhead is a locator system used in Amateur radio. If you receive a grid locator, the following calculations are helpful in converting to latitude/longitude. Please note the Maidenhead grid locator is NOT an exact location. It is a large square that contains a coordinate within.

Maidenhead to Latitude and Longitude

Using a spreadsheet program, you can enter a Maidenhead grid locator and calculate the latitude and longitude.

You can use the following as an example and an aid to check if the formula works for you.

Source: CO80mc 50.1041666666667 N, 122.958333333333 W
Target: CN65wl 45.4791666666667 N, 126.125 W

Note: The last two characters are lowercase. The formulas in the spreadsheet are case-sensitive.

Below, line 1 indicates row 1 column headings in a spreadsheet, and lines 2 and 3 indicate the Maidenhead grid locator entries (Column A). Columns B and C are calculated.

1Maidenhead {A1}Latitude {B1}Longitude {C1}
2CO80mc{B2}{C2}
3CN65wl{B3}{C3}

{B2} =(CODE(MID(A2,2,1))-65)*10 + VALUE(MID(A2,4,1)) + (CODE(MID(A2,6,1))-97)/24 + 1/48 - 90

{C2} =(CODE(MID(A2,1,1))-65)*20 + VALUE(MID(A2,3,1))*2 + (CODE(MID(A2,5,1))-97)/12 + 1/24 - 180

{B3} =(CODE(MID(A3,2,1))-65)*10 + VALUE(MID(A3,4,1)) + (CODE(MID(A3,6,1))-97)/24 + 1/48 - 90

{C3} =(CODE(MID(A3,1,1))-65)*20 + VALUE(MID(A3,3,1))*2 + (CODE(MID(A3,5,1))-97)/12 + 1/24 - 180

Source: Stack Exchange Retrieved on 2021-11-14

Calculate Distance and Bearing

Using a spreadsheet program, you can enter two locations and calculate distance and bearing.

You can use the following as an example and an aid to check if the formula works for you. The example below represents a precise location for two points within CO80mc and CN65wl.

Source: 50.1149914 N, 122.9580637 W
Target: 50.1149914 N, 122.9580637 W

The calculated (rounded) distance is 566 km, Bearing (source) 206°, and Bearing (target) 26°.

Below, line 5 indicates row one column headings in a spreadsheet, and line 6 indicates the entries in row 6. Columns E, F, and G are calculated.

5Source Latitude {A1}Source Longitude {B1}Target Latitude {C1}Target Longitude {D1}Distance (km) {E1}Bearing (source) {F1}Bearing (target) {G1}
650.1149914-122.958063745.4886843 N-126.1298819 W{E6}{F6}{G6}

Replace {E6} in your spreadsheet with: =ACOS(COS(RADIANS(90-A6))*COS(RADIANS(90-C6))+SIN(RADIANS(90-A6))*SIN(RADIANS(90-C6))*COS(RADIANS(B6-D6)))*6371

Replace {F6} in your spreadsheet with: =IF(E6>0,MOD((DEGREES(ATAN2(COS(RADIANS(A6))*SIN(RADIANS(C6))-SIN(RADIANS(A6))*COS(RADIANS(C6))*COS(RADIANS(D6-B6)),SIN(RADIANS(D6-B6))*COS(RADIANS(C6))))+360),360), 0)

Replace {G6} in your spreadsheet with: =IF(E6>0,MOD((DEGREES(ATAN2(COS(RADIANS(A6))*SIN(RADIANS(C6))-SIN(RADIANS(A6))*COS(RADIANS(C6))*COS(RADIANS(D6-B6)),SIN(RADIANS(D6-B6))*COS(RADIANS(C6))))+180),360), 0)

Source: Movable Type Scripts Retrieved on 2021-11-14

The above formulas are attached in this excel file.

Scroll to Top