Skip to content
Advertisement

How to calculate the coordinates of the second point on the map?

Example pictureI have the coordinates of the first point on the map, there is a distance between the points and there are degrees of rotation relative to the cardinal points (from the compass). Please tell me how to calculate the coordinates of the second point on the map?

I tried to take the formula for finding the distance between points and rebuild it, but I cannot figure out how to use the degrees of rotation and in the end I got confused completely.

Advertisement

Answer

This question can have a variety of answers, depending on what exactly you mean by latitude, longitude and compass, and what accuracy you require.

The simplest case is that the latitude and longitude are relative to a spherical model of the earth (with earth radius R) and that sub metre accuracy is enough. Then we can compute:

lat1Rad = lat1 * pi/180 // latitude of source point in radians
lon1Rad = lon1 * pi/180 // longitude of source point in radians
slat = R  // R is earth radius 
slon = R*cos( lat1Rad)
bRad = compass*pi/180  // compass reading in radians
dN = dist*cos( bRad)   // change in northing
dE = dist*sin( bRad)   // change in easting
lat2Rad = lat1Rad + dN/slat  // target latitude in radians
lon2Rad = remainder( lon2Rad + dE/slon, 2.0*pi)  // target longitude in radians

This is just plane geometry, except that the scale of longitude (ie how much a small change in longitude is worth in metres) varies with the cosine of the latitude.

That should be good to better than a millimetre over a distance of 100m, and better than a centimetre for distances up to 1km.

You might wonder at the call to remainder in computing the longitiude. It’s not required (ie could be omitted) in your specific case, but over the years I’ve got into the habit of writing code that will work even if you are close to 180 East (or West)

Some more complicated cases: Your lat and long could be relative to an ellipsoidal model of the earth (for example WGS84). In that case the slat and slon variables need to be computed differently, using the details of the ellipsoid used.

Your compass is a magnetic device. In that case you need to correct the compass for magnetic variation (aka magnetic declination) to get a reading relative to true north.

You require higher accuracy. It is usual in geodesy to interpret the problem to be about following the geodesic (great circle for a spherical earth) between the points. Then the code needs to be rewritten entirely. For a spherical earth there are (relatively) simple formulae to use. For a ellipsoidal earth there is code around that will do this computation.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement