Jamie Gaskins

Ruby/Rails developer, coffee addict

Mapping vs Every Other Coordinate System

Published Dec 15, 2014

Last week, I spent a day animating an SVG around a Google Map and it occurred to me that the way we represent polar/Cartesian coordinates is very different from the way map coordinates work.

North is East

The polar axis in a polar coordinate system points to the right. This means 0° is east. On a map, 0° is north.

Run Over Rise

Map coordinates are expressed as (latitude, longitude). Since latitude is the arc from the equator (the horizontal axis) and longitude is the arc from the prime meridian (the vertical axis), this means they are expressed as (y, x). Cartesian coordinates are expressed as (x, y).

Arctangent is a stupid function

This has nothing to do with maps, but everything to do with converting rectangular to polar coordinates. The angle (𝜃 in polar coordinates) is the arctan of the slope, but there is a special case you have to check — if the "run" of the slope is negative, you add π or 180° (depending on whether you're using radians or degrees) to the result.

I understand why this is, but I'd forgotten about it because the last time I did this was in 11th-grade, so I spent half the day trying to figure out why the damn car was going backward around the map half the time.