# Showing heading on a rectangular map projection

I'm creating an app which displays a map in the form of a basic lat/long grid along with the user's location and heading. I'm currently plotting the grid lines and user location with an equirectangular projection (i.e. simply treating longitude/latitude as x/y coordinates on a rectangular grid) which works fine, but I have a few questions when it comes to plotting the user's heading.

To calculate the current heading, I'm using the formula under the 'Bearing' section of this page. Whenever I get a location update containing a new latitude/longitude, I put it into the formula along with the previous latitude/longitude to find the bearing between them.

However, when I plot my calculated heading arrow on the map, the arrow does not align with the line drawn between the user's current location and their last location, unless you're at the equator. I'm guessing this is because the equirectangular projection distorts a circle into an ellipse as seen here (i.e. it's not conformal).

So, I'm wondering how I might 'transform' the heading value calculated using the above method so that it accounts for this distortion, and the arrow points in the correct direction? I know that one solution would be simply to do atan2(deltaLat, deltaLon) but I'd much prefer to start with a proper heading value and then transform it to a displayable angle depending on which map projection I choose.

Note that the user is not travelling large distances between each location update, so I wouldn't expect to have to worry about the heading changing along a great circle.

Side note: am I right in thinking that if I used a Mercator projection, I could just plot the heading as-is because the distortion does not occur at extreme latitudes?

• Yes, the advantage of Mercator is that a line drawn on it is a rhumb line - a line of consistent heading. Commented Apr 5, 2017 at 13:37
• Welcome to GIS SE. Can you explain, via Edit, how you determine the heading? Commented Apr 5, 2017 at 15:21
• Made an edit :) In short, I'm calculating the bearing between my previous location and my current location every time I get a fix, using the 'bearing' formula here. Commented Apr 5, 2017 at 15:45
• It's not clear what you're actually doing. The "bearing" computed in your reference is relative to spherical coordinates, so of course it needs adjusting to be mapped: you can't suppose it will give you the angle on the map. On the other hand, if you were simply to compute a first difference approximation to the tangent in the map coordinates--in other words, to treat (lat, lon) as Cartesian coordinates--then all will be fine. If your lat-lon points are relatively far apart, consider splining the sequence of plots and computing the tangent direction of the spline by differentiating it. Commented Apr 7, 2017 at 19:05

Some basic principles:

The shortest path over a globe – called a great circle, orthodrome or geodesic – is, in general, different from a line of constant bearing – called a rhumb line or loxodrome – and when projected, in general, neither one is shown as a straight line on a map.

The exceptions on the equi-rectangular projection are that (a) the equator and all meridians are great circles and appear straight, and (b) all parallels and all meridians are rhumb lines and appear straight.

Whenever you are discussing bearings of a path on a globe, you need to be clear on exactly what you are saying. On the geodetic calculator site you reference, a great circle has two significant bearings, an initial and a final, as well as a mid-point bearing. And they are all different.

Two special projections are the gnomonic, on which all great circles appear as straight lines, and the mercator, on which all rhumb lines appear as straight lines.

A general truth about conformal (or orthomorphic) projections, of which the mercator is an example, is that any angle between two lines on a globe is preserved when those lines are projected to a map.

In conclusion, an elongated bearing line will not generally align with a great circle route, and hence will not pass through a previous point.

• Thanks for the reply. First, I'm aware that bearing changes along a great circle but for my purposes, I am assuming that the initial bearing is all I really need to think about as I'm measuring heading using locations which aren't likely to be further than a few hundred metres apart. I'm also aware that the equirectangular projection is non-conformal, which is the root of my problem. What I'm wondering is whether there's any way to transform my calculated heading so that it will point in the 'distorted' direction on my projected map? Commented Apr 5, 2017 at 16:07
• ...I suspect that I might end up either a) using atan2(deltaLat, deltaLon) to calculate the distorted heading directly from the points plotted on the grid or b) start using a Mercator projection, but I'd like to know if there's a transformation so that I can make use of my 'proper' heading that I have calculated. Commented Apr 5, 2017 at 16:08