# Spatial Reference Systems

## From PostGIS in Action, Third Edition by Regina O. Obe and Leo S. Hsu

________________________________________________________

Take 37% off PostGIS in Action, Third Edition by entering fccobe into the discount code box at checkout at manning.com.
________________________________________________________

Using sample data to learn the basics of PostGIS is an excellent first step: you’re immediately rewarded with results without facing the messiness of real-world data. But reality is messy. In this article we confront the fact that our earth isn’t the nice beach ball that we thought it was. The same exact point on the face of the earth could be described differently by different groups. With time, the point shifts and the accuracy of our instrumentation gets better.

One big conundrum facing geographers is that an absolute frame of reference is missing. Our frame of reference is the earth itself, on which we’re trying to establish absolute positions. The earth spins, tilts, and sometimes even wobbles. The measurements we take of the earth aren’t durable. The best we can do is make known how and when we made our measurements.

We begin this article by discussing different types of spatial reference systems (SRS). We then follow up with sections on choosing suitable SRSs and uncovering the SRS of the source data when it isn’t apparent.

The art and science of modeling our bulbous earth and getting a 2D representation on paper has been around from antiquity. Geodetics is the science of measuring and modeling the earth. Cartography is the science of representing the earth on flat maps. The intricacies of these two venerated sciences are far beyond the scope of this article, but together with a lot of math, they produce something of utmost importance to GIS: spatial reference systems (SRSs).

In this article, we’re not going to take the easy way out by accepting spatial reference systems without understanding them. We’ll also avoid the path of arcane mathematics necessary to study the science in all its glory. We take a middle road to provide more than a one-sentence explanation of SRSs when your kids finally get around to asking you about them. Our journey into the real world begins.

## Spatial reference systems: What are they?

Spatial reference systems is one of the more abstruse topics in GIS, attributable to the loose way in which people use the term spatial reference system, and SRS isn’t glamourous. If GIS is Disneyland, then SRS is the bookkeeping necessary to keep the theme park operation afloat.

Take any two paper maps having one point in common; overlay one atop the other using the common point as a reference. Both maps represent sections of the earth, but unless you’re extremely lucky, the two maps have no geographical relation to each other. Travel five centimeters on one map and you end up on another street. Travel five centimeters on the other and you’re up on another continent. Your two maps don’t overlay well because they don’t share a common spatial reference system.

The GIS practitioner must be acquainted with SRSs in order to combine data from disparate sources. Several universally accepted systems make this task easy without delving into the nuances. The most common SRS authority is the European Petroleum Survey Group (EPSG) numbering system. Take any two sources of data with the same EPSG number, and you’ll be guaranteed a perfect overlay. But EPSG is a recent SRS numbering system, if you uncover data from a few decades ago, you won’t find an EPSG number. You’ll have no choice but to delve into the constituent pieces that form an SRS: ellipsoid, datum, and projection.

## Geoids

From outer space, our good earth appears spherical, often described as a blue marble. To anyone living on its surface, though, nothing could be further from the truth. The slick glossy surface seen from outer space devolves into mountain ranges, canyons, fissures, and ocean trenches with mind boggling depth. The surface of the earth with all its nooks and crannies resembles a slightly charred English muffin much more than a lustrous marble. Even the idea of the earth being spherical isn’t accurate, because the equator bulges out, a trip around the equator is 42.72 km longer than a trip around one of the meridians.

In light of the fact that we have a deeply pitted and somewhat squashed orange-like ball under our feet, what can we do when it comes to identifying a point on its surface? With our new GPS toys, we could conceivably represent every square meter on earth as a satellite map, assigning it a spherical 3D-coordinate, and be done with it. This is the approach taken by many digital elevation models. We may even be able to pin our reference on a celestial object (man-made or otherwise), removing the annoyance of having to use a reference point on our shifty planet. Though these measuring methodologies could certainly become the norm one day soon, we still need a simpler, more computationally cost-effective model for most use cases. Because we can locate a point on, above, or within earth to twenty decimal places, doesn’t mean we should.

A model, by definition, is a simplified representation of reality. All models are inherently flawed in some way or other, but in exchange for their shortcomings, they provide us with a more expedient way of solving our problems. Model must match the mission. A cartoonish map of New York City is fine for a tourist, but disastrous for a helicopter pilot navigating the Hudson skyway. A starting point for any geodesic model is deciding what constitutes the surface of the earth. Perhaps something you haven’t given much thought to, but do you use the mean sea level? Do you flatten the peaks and the valleys? What about the ocean? Do you consider the ocean surface or the ocean depth? And what about plate tectontics? Should our surface be the plates or the surface of the molten goo underneath? Once you start thinking about earth surface, a bewildering number of possibilities jump at you, but they all suffer from a common problem — you can’t establish a standard of measurement that works for all portions of the planet. Take the notion of sea level. Someone in Cardiff, Wales, can say that her house is 50 meters above the sea during low tide and use this as a reference against her neighbor’s house. Suppose a fellow in Pago Pago has a small house and measures his house also to be 50 meters above sea level. What can we say about the elevation of the two houses relative to each other? Not much. Sea level varies from place to place relative to the center of the earth. And even the notion of center of the earth is ambiguous.

Along comes Gauss, who, with the help of a crude pendulum, determined in the early nineteenth century that the surface of the earth can be defined, with some consistency, using gravitational measurements. Though he lacked a digital gravity meter, he envisioned the idea of going around the surface of the globe with such a device, like a simple pendulum, and map out a surface where gravity was constant — an equipotential surface. This is the basic idea of what we call the geoid. We take gravity readings at various sea levels to come up with a consensus and then use this constant gravitational force to map out an equi-gravitational surface around the globe. Many consider the geoid to be the true figure of the earth.

Surprisingly, the geoid is far from spherical; see the figure below. Don’t forget that the core of the earth isn’t homogenous. Mass is distributed unevenly, giving rise to bulges and craters that rival those found on the lunar surface. The advent of the geoid didn’t simplify matters. On the contrary, it created even more headaches. The true surface of the earth is now even less marble-like, and even a slightly squashed orange is no longer a reasonable approximation.

Although the geoid is rarely mentioned in GIS, it’s the foundation of both planar and geodetic models. In the next section, we’ll discuss the more commonly used ellipsoids, which are simplifications of the geoid and are generally good enough for most geographic modeling needs.

## Ellipsoids

Ancient Greeks were first recorded as having used the ellipsoids to model the earth.

Geometrically, an ellipsoid is nothing but a 3D ellipse, an ellipse with an added Z-axis. Like a sphere, an ellipsoid has three radii. Unlike a sphere the length of the radii can vary. When two radii are the same length, the ellipsoid is also called a spheroid. Notation-wise, a and b generally refer to the equatorial radii (along the X and Y axes), and c is the polar radius (along the Z axis). A perfect sphere is defined by a = b = c; an oblate spheroid is where a = b, but c > a. Our earth closely approximates an oblate spheroid; think Clementines.

By varying the equatorial and polar radii on the ellipsoid, you can model the equatorial bulge. At some point in the history of geodesy, it was accepted that one ellipsoid could be used all around the world as a reference ellipsoid. Everyone could locate each other by finding their placement on this reference ellipsoid.

The appearance of Gauss’ geoid shattered the idea of a single standard ellipsoid. One look at the geoid shows why: the curvature of the geoid varies wildly from place to place. An ellipsoid that fits the curvature for one spot may be woefully inaccurate for another; see the figure below. Instead of one ellipsoid to rule us all, people on different continents wanted their own ellipsoids to better reflect the regional curvature of the earth. This gave rise to the multitude of ellipsoids in use today.

This was all well and good when we people on different continents communicated little with each other, and ships only steered in the direction of whales and galleons. This use of different ellipsoid became an obstacle as geologist from different countries collaborated to mine precious minerals (oil). Ships outgrew their sails and were overtaken by airplanes. Having to toggle between different ellipsoids became an annoyance. Fortunately, today the world has settled on two ellipsoids: the World Geodetic System (WGS 84) and the Geodetic Reference System (GRS 80), with WGS 84 becoming the standard of choice. WGS 84 is the basis of all GPS navigation systems.

The 80 and 84 in GRS 80 and WGS 84 stand for 1980 and 1984, when the standards came out, and the two ellipsoids are similar.

To call WGS 84 an ellipsoid isn’t quite accurate. The WGS 84 GPS system in use has a geoid component as well. To be precise, the present WGS 84 system uses the 1996 Earth Gravitational Model (EGM96) geoid and it’s the ellipsoid that best fits the geoid model for the selected survey points in the set. Many ellipsoids have been used over the years, and some continue to be used because of their better fit for a particular region. All historical data is still referenced against other ellipsoids. The following table lists some common ellipsoids and their ellipsoidal parameters.

One common old ellipsoid is Clarke 1866, and it’s close enough to the NAD 27 ellipsoid that they’re interchangeable for most applications.

In the next section we’ll discuss the concept of datums and how they fit into the overall picture of the spatial reference system.

## Lon/lat, but which ellipsoid?

Even though humanity has used longitude and latitude for centuries, the longitude and latitude coordinates of yesterday are probably not the ones we use today. Mariners in the Renaissance didn’t have the sophisticated electronics we have now, and their guess at the location of the poles was specious at best. One more thing, earth changes shape over time. This is why it’s important to not only pinpoint a location by lon/lat. You can have NAD 27 lon/lat, NAD 80 lon/lat, and WGS 84 lon/lat, and each is subtly different. A pirate during the golden age of pirates probably recorded his buried treasures using lon/lat significant to one-tenth of a degree. He probably didn’t mention ellipsoid. Good luck trying to find his treasure.

Nowadays, when referring to lon/lat, WGS 84 datum and WGS 84 ellipsoid in lon/lat units are implied.

## Datum

The ellipsoid only models the overall shape of the earth. After picking out an ellipsoid, you need to anchor it to use it for real-world navigation. Every ellipsoid which isn’t a perfect sphere has two poles. This is where the axis arrives at the surface. These ellipsoid poles must be tagged permanently to true points on earth. This is where the datum comes into play. Even if two reference systems use the same ellipsoid, they could still have different anchors, or datum, on earth.

The simplest example of a datum is to look at the tilt between the geographic pole and the magnetic pole. In both models, the earth has the same spherical shape, but one is anchored at the North Pole, and the other is somewhere near northern Canada.

To anchor an ellipsoid to a point on earth, you need two types of datum: a horizontal datum to specify where on the plane of the earth to pin down the ellipsoid and a vertical datum to specify the height. For example, the North American Datum of 1927 (NAD 27) is anchored at Meades Ranch in Kansas because it’s close to the geographical centroid of the United States. NAD 27 is both a horizontal and a vertical datum.

Here are some commonly used datums:

• NAD 83 (North American Datum 1983, which is often accompanied by the GRS 80 ellipsoid)
• NAD 27 (North American Datum 1927, which is generally accompanied by the Clarke 1866/NAD 27 ellipsoid)
• European Datum 1950
• Australian Geodetic System 1984

## Coordinate reference system

Many people confuse coordinate reference systems with spatial reference systems. A coordinate reference system is only one necessary ingredient which goes into the making of an SRS and isn’t the SRS itself. To identify a point on your reference ellipsoid, you need a coordinate system.

The most popular coordinate reference system for use on a reference ellipsoid is the geographical coordinate system (also known as geodetic coordinate system or as lon/lat). You’re already intimately familiar with this coordinate system. You find the two poles on an ellipsoid and draw longitude (meridian) lines from pole to pole. You then find the equator of your ellipsoid and start drawing latitude lines.

Keep in mind that even though you may only have seen geographical coordinate systems used on a globe, the concept applies to any reference ellipsoid. For that matter, it applies to anything resembling an ellipsoid. For instance, a watermelon has nice longitudinal bands on its surface.

## Spatial reference system essentials

Let’s summarize what we’ve discussed about spatial reference systems:

You start by modeling the earth using some variant of a reference ellipsoid, which should be the ellipsoid that deviates least from the geoid for the regions on earth you care about.

You use a datum to pin the ellipsoid to an actual place on earth, and you assign a coordinate reference system to the ellipsoid to identify every point on the surface. For example, the zero milestone in Washington, D.C., is W -77.03655 and N 38.8951 (in spatial, x: -77.03655, y: 38.8951) on a WGS 84 ellipsoid using the WGS 84 datum; on the NAD 27 datum and Clarke 1866 ellipsoid, this is W -77.03685, N 38.8950.

We can quit at this point, because we have all the elements necessary to tag every location on earth. We can even develop transformation algorithms to convert coordinates based on one ellipsoid to another. Many sources of geographic data stop at this point and don’t go on to the next step of projecting the data onto a flat surface. We term this data unprojected data. All data served up in the form of latitude and longitude is unprojected.

You can do quite a bit with unprojected data. By using the great circle distance formula, you can get distances between any two points. You can also use it to navigate to and from any points on earth.

Written by