Projections and datums in

web mapping: an introduction

Lyzi Diamond | NACIS 2017 | Montreal, QC

web mapping: an introduction

ARE YOU READY TO TALK ABOUT MATH?!

This talk is based on a blog post I wrote, so don't scramble to write everything down.

This talk:

- A reintroduction to
**projections and datums**(aka*geodesy*) - An overview of the
*coordinate systems*we use in web mapping - An impassioned defense of
**spherical mercator**(maybe) - Lots of bad doodles by yours truly
*(not an artist)*

1. Projections, datums, coordinate systems, **WHY?!**

A truth: *Maps are tools for communication*
In the cartography context, we think about communicating specific types of information visually on the map. But the visual map is only a small part of what geospatial technology allows us to do. Spatial data is used to find places, calculate distances, analyze phenomena. The visual output is great and important, but underneath it is a bunch of other information that is also important and without it, we would be lost. Literally and figuratively.

In order to communicate about *physical locations*, we need to have a **common system** that we can use as a guide.

In our mappy world, these are called *coordinate reference systems*, and they determine how maps **look**, how data is **stored**, and how distance is **calculated**.
"Walk three blocks and then turn left" doesn't work as well if you don't know where the directions are starting from.

Geodesy: measuring the earth

What does the Earth look like?

A sphere? Nope.

A spheroid? Nope.

An ellipsoid? Nope.

Its own weird crazy shape? Yes! (thx 4 this img Mike Foster)

in reality the earth is its own crazy wonky lumpy shape that is constantly changing in four dimensions with mass movements and human behavior. It also has inconsistent density (and thus an inconsistent gravitational pull), making it even harder to model.

The *real* shape of the earth is **too complex** to be useful as a reference for measurement.

Instead, we use a **reference ellipsoid** to approximate the planet's surface.
Instead, we use a reference ellipsoid as an approximation of the surface of the earth. A reference ellipsoid is a mathematically-defined surface that roughly matches the model of the earth when its topographical features are removed (the lovely lumpy geoid, a model of the earth with assumed equal density).

Just like in dating, the perfect mathematical ellipsoid does not exist.

There is not a single canonical ellipsoid that is used to measure the earth at every location. Because a reference ellipsoid is an approximation, there are locations where an ellipsoid exactly matches the geoid and there are locations where an ellipsoid is way way off. In some of these locations, a different reference ellipsoid is used that better matches the earth’s surface at those locations.

Okay, so now we've picked our **reference ellipsoid**. What's next?

Puppies!

Once we've defined our *reference ellipsoid*, we have a shape on which we can place a **coordinate system**.

A **coordinate system** defines locations on that surface that can be used as *reference points* for measurement.
This is huge — imagine trying to tell someone how to get to your house without using miles, meters, or any other standardized system of measurement. Imagine trying to assess property values without the concept of acres and square footage. A coordinate system is a way to standardize the way we describe locations on a map. It’s the common understanding that allows a person to go out in the world, measure some stuff, and know with confidence that the measurements they took will show up in the right place on any map that anyone creates with that data.

There are *two* types of coordinate systems:

**Geographic**coordinate systems**Projected**coordinate systems

- A
*unit of measurement*for angles (we use degrees) - A
*prime meridian* - A
*geodetic datum*

The *datum* is the mathematical equation that connects our **reference ellipsoid** to the Earth's surface.

Because, as we discussed before, the reference ellipsoid is not related to the Earth's surface in a regular way in every location, certain datums are going to work better for different parts of the planet just as certain ellipsoids work better for different parts of the planet.

They are also a *grid* used as a reference for locations on the planet, but translate the **three-dimensional grid** to a **two-dimensional plane** (like a piece of paper or a screen).

A projected coordinate system is the *mathematical definition* of a projection.Note: a projected coordinate system includes a lot more definitions than just the projection. These include the center of the projection, scale factor, and others.

Mid-talk recap:

- To make maps, we need to have a
*common system for measurement* - To make that
*common system for measurement*, we need to define a**reference ellipsoid** - Once we have our
**reference ellipsoid**, we can decide on a coordinate system

2. Okay. So what about *web maps*?

WAIT FIRST:

1.5. What are these EPSG codes I keep hearing about?

European Petroleum Survey Group

Quick note on naming: coordinate systems (projected and geographic) are often identified by an EPSG code. EPSG stands for European Petroleum Survey Group, an organization involved in best practices for surveying and applied geodesy. In 2005, EPSG was absorbed into the International Association of Oil & Gas Producers (IOGP), but the list of coordinate systems they maintained is still called the EPSG Geodetic Parameter Dataset.

2. Okay. So what about *web maps*?

There are *two* coordinate systems we need to think about when it comes to web maps: **EPSG:4326 (WGS 84)** and EPSG:3857 (Web Mercator/Pseudo Mercator). They are *both* used in web mapping, but in *different* ways.

There is *no way* to visualize the WGS84 coordinate system on a two-dimensional plane (map), so most software programs project these coordinates using an **equirectangular** projection (Plate-Carrée).

It uses the **WGS 84 coordinate system**, which uses the WGS 84 ellipsoid, but then goes another step and projects the coordinates onto a *sphere*.

Two ellipsoids?!

Why Web Mercator? *Pros:*

- it makes the map into a
**square** - it's the
**industry standard** - it preserves
**directionality** - it enables a global map that
**mostly looks good**most places where there are people

"[T]echnology is a result of its environment and requirements, not any absolute value: spherical mercator fits the role of a simple, fast, pannable, and zoomable projection like no other common projection." - Tom MacWright

- it's not attractive
- it doesn't cover the whole planet
- there is no programmatic way to represent a coordinate system that relies on two different ellipsoids

So. What do we do?

We *store* data in WGS 84 (EPSG:4326), but **display** it in Web Mercator (EPSG:3857).

We *store* data in WGS 84 (EPSG:4326), but **display** it in Web Mercator (EPSG:3857).

(Yes, that's what we've been leading up to.)

What does this mean for **you** when making web maps?

1. If you're making a (typical) web map, *store your data in geographic (unprojected) coordinates*.

3. If someone says they want to see their data in WGS 84, *project it onto Platte-Carré* for them. (Then maybe ask them why they want that.)

4. If you're *upset* that you can't easily make web maps in other projections, guess what? **You can!** Just not with out-of-the-box, point-and-click tools.

Ultimately, these standards allow us to use geospatial data more deeply: they give us a common system to communicate, build tools, and grow/learn/play together in harmony.

So when you're upset about Web Mercator, remember that we're using it for the greater good! 💕💖💗