Where in the world are you, really?

Jacob Baskin
Coord
Published in
6 min readMay 14, 2018

An introduction to geographic coordinate systems

At Coord, one of the very first things we had to do was pick a coordinate system to use when storing and manipulating our geospatial data. You may be thinking, “Why don’t you just use latitude and longitude?” We wondered that too! But soon we learned that we needed to care about coordinate systems, at least a little bit. So: why are there so many different ways of talking about where you are on the earth? What’s the difference between them? What do latitude and longitude even mean? And why should you never, ever use Google Maps at sea?

Read on to find out!

Introducing the Earth

Mostly harmless.

The earth is a bumpy squashed spheroid that’s constantly rotating and moving through space. But every geographic coordinate system assigns a fixed, unique identifier to points on the earth’s surface. So our first task will be picking a frame of reference where points on the earth stay in the same place. In other words, we need to fix the position of the earth to one place.

The most basic possible coordinate system that does this is called, unsurprisingly, earth-centered earth-fixed (or ECEF for short). In ECEF coordinates, the center of the earth is (0, 0, 0), the north pole goes straight up along the Z axis, and the prime meridian goes straight along the X axis.

The relationship between ECEF, latitude/longitude, and the shape of the earth.

If you’re a satellite, this is a very useful coordinate system: in fact, GPS uses ECEF coordinates. But for us on the surface of the earth, it’s less valuable, since we don’t even know where the earth’s surface is! Most of the computations we want to do happen on or near the earth’s surface: When we say that New York is 3,450 miles from London, we mean that that’s the distance traveling along the earth’s surface, not through it. And when we talk about a location, we mostly want to position it relative to other points on the surface.

Latitude, Longitude, and the Ellipsoid

If you only care about points on the earth’s surface, you can use latitude and longitude. As the above diagram shows, if you draw a line from a point on the earth’s surface to the center of the earth, latitude and longitude represent the angles between that line and the equator and the prime meridian, respectively. Latitude and longitude are a natural coordinate system for the surface of a spheroid, and they’re easy to compute from ECEF coordinates, meaning you can find them out from a GPS receiver.

Say you have two latitudes and longitudes and you want to know how far apart they are. To figure this out, you have to know the shape of the earth’s surface — and, as you may have heard, earth isn’t perfectly spherical. In 1984, geographers took survey data from all around the world and created a reference ellipsoid: a standard model for the shape of the earth. It uses two parameters (“a” and “b” in the diagram above) to define how wide and tall the earth is (about 6,378 km and 6,357 km, respectively). Using these parameters, you can compute the distance between any two points on the earth’s surface if you know their latitudes and longitudes.

Flattening the Earth

So, why don’t we just use latitude and longitude everywhere? There’s a big problem with using the ellipsoid: it’s very complicated! There’s no exact equation that will tell you the distance between two points on the reference ellipsoid: you have to use iterative method called Vincenty’s Formulae. And if you want to do more complicated math, like figuring out the area of a polygon or seeing if two lines intersect, it can be even harder. Wouldn’t it be great if we could map the earth’s surface to a flat plane? Then we can use our old friends like the Pythagorean theorem to do all the calculations we need.

It can be tempting to pretend that latitudes and longitudes are coordinates on a flat rectangle. This is called a plate carrée or equirectangular projection.

The earth in an equirectangular projection.

There are a few problems with this solution. The first is: what do you do about the points near the edges of the rectangle? But even if you’re not near the poles or the Aleutian islands, you still have to worry about degrees of longitude being very different in length depending on how far north or south you are. No matter how far you zoom in, your map will still be stretched out from east to west, unless you’re very close to the equator.

While it turns out there’s no perfect way to map an ellipsoid (or even a sphere) directly to a flat surface, we know firsthand that for short distances, we can pretty much pretend that the earth is flat. So, are there mappings from an ellipsoid to a sphere that work well when you’re zoomed in far enough?

The Mercator Projection

You may have heard of the Mercator projection. As you can see below, it’s very distorted on a worldwide scale, but it has a great property: it’s conformal. More or less, this means that if you zoom in enough, everything will be the right shape. Even though Mercator projections don’t make a very good world map, they’re the basis for almost all small-scale maps you will ever see.

The earth in a Mercator projection

If you want to use a Mercator projection, you need to know the scale to use, and as you can see from the example, the scale varies greatly depending on your latitude. So a bunch of organizations have designed systems that give you very accurate scaling factors over a limited distance.

One of these is called UTM, for Universal Transverse Mercator (transverse means that the projections are done with a point other than the North Pole at the top of the map). UTM defines a grid system with a projection for every square. The parameters of the projection are designed so that 1 unit in the projection’s coordinate system is always one meter. As long as you only use that projection within its defined square, you’ll get very accurate results (within 1 part in 1,000).

The UTM grid

Within the US, the state plane coordinate system works similarly to UTM but creates “grid squares” that align better to US jurisdictional boundaries. Other countries have similar systems of their own.

The state plane system

Web Mercator

When online mapping systems came along, they didn’t want to mess around with UTM or State Planes. They wanted a single coordinate system they could use across the entire world that still made their math easy. They wound up using a variant of Mercator called “Web Mercator”, that assumes the earth is a perfect sphere. This gives some inaccuracy (up to 0.5%), which is why you should never use Google Maps on a boat! But for day-to-day navigation, it’s perfectly fine.

What Should You Use?

Now that we’ve made it all the way from space to the Internet, you may be wondering: which coordinate system is right for me? Here’s what we do at Coord in order to map the locations of fixed and moving assets:

  • For storing and sharing the locations of points on the earth’s surface, use latitude and longitude (referenced to the WGS 84 ellipsoid). All of Coord’s mobility APIs return latitudes and longitudes, even though we sometimes use other coordinate systems internally.
  • For displaying on top of online maps and doing fast, moderately accurate geospatial math across the whole world, use web mercator.
  • When you’re working in a smaller geographical area, use UTM, state plane, or another grid-based conformal coordinate system.
  • If you’re launching satellites or building GPS receivers, use ECEF.

Hopefully this has helped clear up some of the confusion around the different geographical coordinate systems and why they exist. Happy mapping!

--

--

Jacob Baskin
Coord
Editor for

CTO at Coord, bringing mobility online and connecting software to the physical world.