# Hack 28. Experiment with Different Cartographic Projections

There are lots of ways to depict a round planet on a flat plane, but, fortunately, there are also versatile tools for exploring the aesthetic compromises embodied in different cartographic projections.

One of the main challenges of mapping our world is how to represent its round surface on the flat plane of a map. Most projections involve some process of projecting Earth's spheroid surface directly onto a flat plane, or onto the surface of another figure which can be "unwrapped" into a flat plane without warping or tearing, such as a cylinder or cone. The projection surface may be aligned in a conventional, transverse (at a right angle), or oblique (i.e., at some other angle) fashion.

The projection process necessarily introduces distortions of one kind or another. Different cartographic projections make different choices about the trade-offs inherent in preserving one or more aspects of the planet's surface, at the expense of others. Table 3-1 outlines some of the properties that projections can preserve or distort.

Table 3-1. Some properties of cartographic projections

Property

Map feature

Preserved by...

Area

Relative areas of landmasses

Peters, Mollweide, Albers Equal-Area Conic

Conformality

Shapes of landmasses

Mercator, Stereographic, Lambert's Conformal Conic

Direction

The relative direction between two points (useful for navigation)

Mercator, Gnomonic

Distance

Distances from the center of the map

Azimuthal Equidistant

Scale

Ratio of distances on the map versus distances in the world

Many projections, but typically only along meridians or standard parallels

 In general, cartographic distortion tends to increase as one moves away from some "standard" parallels or meridians, which are used as parameters of the projection process. The canonical example of this tendency is Greenland, as depicted on a Mercator projection of the world, looming over North America like Godzilla eyeing downtown Tokyo. This results in part from the Mercator's conventional use of the equator as a standard parallel, which leads it to distort area to terrifyingly swollen proportions near the Poles.

The University of Hawaii's Generic Mapping Tools, or GMT, offer a useful way of experimenting with different map projections. GMT was originally intended for generating maps for inclusion in scientific publications, incorporating a series of useful command-line tools for plotting maps in a broad variety of projections. In addition, GMT includes vector data of reasonable quality of coastlines and political boundaries for the whole world, so it makes worthwhile maps right out of the box. Naturally, it's published under the GNU Public License, so the code and data are all "free as in freedom."

You can get GMT from its homepage at http://gmt.soest.hawaii.edu/. In general, you can follow the installation directions. Binaries are available for Windows from the FTP site, which can be accessed via the mirrors page. If you're running Debian or OS X, we recommend getting GMT from APT or Fink. If you're running Fedora Core or another RPM-based distribution, you can get binary packages of GMT from the Mapping Hacks RPM repository at http://mappinghacks.com/rpm. If you decide to install from source, you can have the web site generate an installation script for you, which, when run, will download and build GMT automatically. If you choose this route, you'll probably want to select shared libraries built with gcc.

 Whichever way you decide to install GMT, don't forget to install the netCDF library as well. Most of the Unix-like installation options will do it for you automatically, but on Windows, you'll want to be sure to grab the precompiled DLL from the GMT FTP site.

Because of its origins in scientific publishing, GMT's primary output format is PostScript, which is great if you plan to make hardcopies of your mapsbecause, as a vector format, PostScript can be scaled to any sizebut a little unwieldy otherwise. Ghostview (a.k.a. gv) is the ideal way to view PostScript on Linux, and GSview is a solid, free PostScript viewer for Windows and OS X. You can find out more about these viewers at http://www.cs.wisc.edu/~ghost/. You should also be able to load and edit PostScript in most modern image editors, including the GIMP, in order to export your maps to other formats, like PNG or JPEG.

 If you want to jump right in and start making these maps on your own, without first installing GMT, try visiting the Online Map Creation site at http://www.aquarius.geomar.de/omc/. There, you'll find a very nice, simplified web-based frontend to GMT, which will allow you to experiment with some simple projections, and probably whet your appetite to do more!

3.8.1. Cylindrical Projections

Frequently used cylindrical projections include Mercator, Transverse Mercator, and Peters projections.

3.8.1.1 The Mercator projection

The one projection that nearly everyone is familiar with, the Mercator, is a classic example of a cylindrical projection, which maps the surface of the planet onto that of a cylinder, and then unwraps it into a flat plane. The following GMT command renders a world map as a Mercator projection:

\$ pscoast -JM18c -R-180/180/-75/85 -Bg30/g15 -G64/255/128 -S64/128/255 >
mercator.ps

We use the pscoast command from GMT to generate a map of the world's landmasses. The -JM18c parameter requests a Mercator projection 18 centimeters wide, which should be big enough to fill a page, more or less. The -R command specifies the area we want mapped, west-by-east and south-by-north, with west longitudes and south latitudes given as negative values. -Bg30/g15 tells GMT we want a grid spaced every 30 degrees longitudinally and every 15 degrees latitudinally. Finally, -G and -S specify the fill colors for land and water areas, respectively. The colors are given in red/green/blue components, so the previous command would yield a light green for land areas and a light blue for water.

 Don't forget that, like many mapping applications, GMT typically expects longitude arguments first, followed by latitude. Think x-y, not latitude-longitude.

Like any good Unix tool, pscoast writes directly to its standard output. We've used shell redirection to dump the map to a file called mercator.ps, which is shown in Figure 3-16.

Figure 3-16. The standard Mercator projection, generated with GMT

Although the Mercator map distorts land area terribly near the poles, it has one enormously useful property, which is that any straight line on a Mercator projection follows a constant bearing in the real world. You can head off in the exact direction indicated by the map and actually arrive at the intended destination. (This can't be done with most cartographic projections, which ordinarily bend straight lines in the real world.) This direction-preserving property has made the Mercator projection valuable to marine navigators for the last 450 years!

3.8.1.2 The Transverse Mercator projection

In [Hack #26], we discuss the enormous utility of the Transverse Mercator projection for mapping small regions of the world with minimal distortion, but they can be used to map larger regions as well. The "transverse" aspect of the Transverse Mercator projection refers to the fact that the cylindrical surface used in the projection gets turned on its side, so that the enormous polar distortion associated with the Mercator projection ends up being pushed out to the sides of the map. This property makes the Transverse Mercator projection useful for mapping regions longer north-by-south than east-by-west, like Chile, Great Britain, or a UTM zone. The following command generates a map as a Transverse Mercator projection similar to one used by the British National Grid system:

\$ pscoast -JT0/18c -R-11/2/50/59 -G64/255/128 -S64/128/255 -W3 -Di -P >
british_isles.ps

The -JT0/18c parameter requests a Transverse Mercator projection centered at 0 degrees longitude, with a width of 18 centimeters. The -R, -G, and -S parameters are used as explained earlier. The -W parameter asks GMT to outline the landmasses, in this case with a line 3 pixels wide. The -Di parameter requests a map based on intermediate resolution data, rather than the default low-res vectors. Finally, -P requests the map be presented portrait orientation, instead of the default landscape orientationthis is a map of an area longer north-by-south, after all. Figure 3-17 shows the result.

Figure 3-17. A Transverse Mercator projection of Great Britain and Ireland

 Although GMT offers five levels of vector resolutioncrude, low, intermediate, high, and fullonly the first three levels are shipped with GMT by default.

Incidentally, you can quite visibly demonstrate the manner in which the Transverse Mercator distorts landmasses away from the central meridian toward the sides, rather than the top and bottom, by mapping the whole world with it, using the following command:

\$ pscoast -JT0/18c -R-180/180/-85/85 -Bg30/g15 -G64/255/128 -S64/128/255 >
world_tm.ps

You can see the result in Figure 3-18. Note the extreme distortion of Central America, western South America, southern India, Sri Lanka, Indonesia, and so on; these are all regions that lie around 90ºE or 90ºW, near the equator. Meanwhile, Greenland and Antarctica, two places often given short shrift in cartographic projections, are shown in their proper size and shape, although Antarctica is bisected in this projection. Try setting the central meridian of a Transverse Mercator world map to your home longitude and see what you end up with.

Figure 3-18. The world in a Transverse Mercator projection, centered on 0º longitude

3.8.1.3 The Peters projection

Other compromises can be made with cylindrical projections. One response to concerns that the Mercator projection distorts the perceived size, and hence the perceived importance, of northern countries at the expense of equatorial countries was the promotion of the Peters projection. The Peters projection is a special case of the basic cylindrical projection, with the standard parallels placed at 45º North and South. Consequently, size and scale are preserved in the Peters projection at those latitudes but distorted elsewhere, in order to preserve relative size overall. Although this makes the shapes of most countries look a bit strange (except for those along the 45th parallel, like Germany or France), the result is a map that at least shows the correct size relationships between countries.

The following pscoast command generates a Peters projection map of the world:

\$ pscoast -JY0/45/18c -R-180/180/-85/85 -Bg30/g15 -G64/255/128 -S64/128/255  -N1
-A5000 > peters.ps

Figure 3-19 shows the map itself. We've used the -JY0/45/18c parameter, which requests a map in the basic cylindrical projection, with its central parallels at 45º. To see what other kinds of maps you can make with the cylindrical projection, try playing with the central meridian and parallels. We've also used the -N1 option to display international borders, and the -A option to filter out features such as lakes and islands that have less than 5,000 km2 total area, to make the map a little neater.

Figure 3-19. The world in a Peters projection

3.8.1.4 The Equidistant Cylindrical projection

The Equidistant Cylindrical (Plate Carrée), projection is a cylindrical projection that treats all lines of latitude as having the same length. Although this results in considerable distortions of scale away from the equator, it makes the calculations needed to plot things on the map trivial, to say the least. pscoast generates Equidistant Cylindrical maps with the -Jq option. We discuss this projection in great detail in [Hack #29] .

3.8.2. Azimuthal Projections

In contrast to cylindrical projections, azimuthal projections are created by projecting, or in some way unwrapping, Earth's surface on to a flat plane. This style of projection lends itself very well to mapping the poles.

3.8.2.1 Stereographic projections

The following pscoast command plots a stereographic projection of the North Pole, which can be seen in Figure 3-20:

\$ pscoast -JG0/90/18c -R-180/180/45/90 -Bg30/g15 -G64/255/128 -S64/128/255  -N1
-A5000 > n_pole.ps

The -JG0/90/18c parameter gives us a stereographic projection of the upper half of the Northern Hemisphere, oriented to 0º longitude, and centered on 90º Northi.e., the North Pole. The stereographic projection is essentially the image that would result if a light were projected through the planet from the opposite side of the planet onto a flat plane touching the surface at exactly one point. As it happens, the stereographic projection is a conformal projection, which, if you'll recall, means that it preserves the shapes of landmasses. Interesting results can be created if different center points and extents are chosentry it!

Figure 3-20. The North Pole, shown in a stereographic projection

3.8.2.2 Orthographic projections

The orthographic projection shows a single hemisphere in perspective. Although it distorts both area and direction, the orthographic projection is popular because, well, it looks like half a globe. pscoast generates orthographic projections with the -JG option. Figure 3-1 from [Hack #22] features a GMT-generated orthographic map centered on San Francisco.

3.8.2.3 The Azimuthal Equidistant projection

The Azimuthal Equidistant projection is just what it sounds like: an azimuthal projection that preserves distance and direction from the center of the map. The result can look pretty interesting. Figure 3-21 shows an Azimuthal Equidistant projection of the world, centered near New York City at 40ºN 75ºW, as generated with the following command:

\$ pscoast -JE-75/40/18c -R-180/180/-90/90 -Bg30 -G64/255/128 -S64/128/255
-A5000 > nyc.ps

Figure 3-21. The world shown relative to distance and direction from New York City

The big blob on the left side is Australia, which is greatly distorted in shape and size due to its extreme distance from New York. In contrast, Figure 3-22 shows the same projection centered in the vicinity of Sydney, at 30ºS 150ºE.

Figure 3-22. The world shown relative to distance and direction from Sydney

3.8.2.4 The Gnomonic projection

Other types of azimuthal projection are possible, as well. The Gnomonic projection is similar to the stereographic projection, except that the "light" source used to project the planet's surface is placed at the center of the planet, instead of at the side opposite the point that the projection surface touches the planet. The following pscoast command generates a Gnomonic projection extending 75 degrees in each direction from 51ºN 0ºE, near London, as shown in Figure 3-23:

\$ pscoast -JF0/51/75/18c -R-180/180/-90/90 -Bg30 -G64/255/128 -S64/128/255
-A5000 > gnomonic.ps

Figure 3-23. A Gnomonic projection of the world, centered near London

The really nifty thing about the Gnomonic projection is that every straight line on a Gnomonic projection follows a great circle, which is the shortest line between two points on the surface of a globe. This makes the Gnomonic projection exceptionally useful for air navigation, in much the same way as the Mercator is useful for marine navigation.

The Gnomonic projection can also be applied to project Earth's surface onto the faces of a polyhedron, such as a cube, instead of a single flat plane. Buckminster Fuller's Dymaxion projection is a special example of a Gnomonic projection of Earth's surface onto an icosahedron, a 20-sided three-dimensional figure. We discuss how to make use of Fuller's projection in [Hack #31] .

3.8.3. Conic Projections

Yet a third type of projection can be constructed by projecting a globe onto the surface of a cone placed over the top of it. If cylindrical projections are traditionally used to map equatorial regions with a minimum of distortion, and azimuthal projections to map polar regions similarly, then conic projections are traditionally used to map the middle latitudes most effectively.

3.8.3.1 Lambert's Conformal Conic projection

With the following command, we can use Lambert's Conformal Conic projection to make a quite reasonable map of Europe, as shown in Figure 3-24:

\$ pscoast -JL15/50/40/65/18c -R-12/50/34/72 -G64/255/128 -S64/128/255 -N1
-A5000 > europe.ps

pscoast takes five arguments for its -JL option, which generates a Lambert's Conformal Conic projection. The first two are the longitude and latitude of the center of the projection, the next two are the two standard parallels of the projectioni.e., the lines of minimum distortionand the last one, of course, is the map size.

Lambert's Conformal Conic projection preserves shapes and is often used to map regions that are broader east-to-west than north-to-south, like the continental United States.

Figure 3-24. Europe, in Lambert's Conformal Conic projection, with standard parallels of 40º and 65º N

3.8.3.2 Albers Equal-Area Conic projection

The Albers Equal-Area Conic projection is another common conic projection, used for purposes similar to that of Lambert's Conformal Conic. As the name suggests, this projection preserves area at the expense of shapes, but the choice between the two is largely aesthetic. For comparison's sake, Figure 3-25 shows the previous Lambert's Conformal Conic map of Europe in gray, with a matching Albers Equal-Area Conic projection overlaid in black. As you can see, two projections differ significantly from each other only as you move away from the projection center.

Figure 3-25. Lambert's Conformal Conic versus Albers Equal-Area

The map shown in Figure 3-25 was made with the following two commands and relies on the handy overlay feature in pscoast:

\$ pscoast -JL15/50/40/65/18c -R-12/50/34/72 -W2/64/64/64 -N1/1/64/64/64
-A5000 -K > overlay.ps
\$ pscoast -JB15/50/40/65/18c -R-12/50/34/72 -W2 -N1 -A5000 -O >>
overlay.ps

The first command generates the Lambert's projection in gray, using the -K command to tell pscoast to leave out the PostScript footers that indicate that the document is finished. The second command appends an Albers Equal-Area projection to the PostScript file using the -JB option, which utilizes the same projection parameters. The -O command tells pscoast to omit the PostScript headers from the second map, which will cause the second map to simply be drawn on top of the first. The -K and -O commands can be combined to successively overlay three or more layers of output from GMT.

3.8.4. Pseudocylindrical Projections

Some projections have a mathematical, rather than geometric, origin. The sinusoidal projection, for example, plots straight parallels against meridians that are curved relative to the cosine of the longitude. Imagine what you might get if you smoothed the ends of the cylinder to a point before attempting a Mercator projection, and you have the basic idea, which is why the sinusoidal projection is sometimes referred to as a pseudocylindrical projection. The result is shown in Figure 3-26, which we generated using the -JI option to pscoast.

Figure 3-26. A sinusoidal projection of the world

Although the sinusoidal projection distorts shapes rather badly away from the equator, it preserves land area, and it has the advantage of being nearly as easy to calculate as the Equidistant Cylindrical projection. Figure 3-27 shows a more aesthetically pleasing sinusoidal map of the world, made by interrupting the projection at 160ºW, 20ºE, and 60ºE.

Figure 3-27. An interrupted sinusoidal projection of the world

Figure 3-27 was generated with a shell script called sinusoidal.sh, containing the following commands:

#!/bin/sh
pscoast -Ji-95/0.05c -R-170/-20/-90/90 -Bg30/g15 -G64/255/128 -S64/128/255
-A5000 -K
pscoast -Ji20/0.05c -R-20/60/-90/90 -Bg30/g15 -G64/255/128 -S64/128/255
-A5000 -X7.5c -O -K
pscoast -Ji125/0.05c -R60/190/-90/90 -Bg30/g15 -G64/255/128 -S64/128/255
-A5000 -X4c -O

The script was then run as follows:

\$ sh ./sinusoidal.sh > sinusoidal.ps

In GMT, if a projection is specified with a lowercase letter (-Ji), rather than an uppercase letter (-JI), then the size measurement is taken to specify the width of a single degree at the equator (or standard parallel), rather than the size of the whole map. A 360-degree map of Earth at 0.05 cm per degree would therefore yield a map 18 cm wide. We used this style of pscoast invocation here because it made the value of the -X option, which specifies how far to offset each interrupted segment of the map along the x axis, a little easier to calculate. (pscoast also supports a -Y option.) Note the use of both -K and -O to allow overlays as described earlier.

3.8.5. Plotting Locations with GMT

We've by no means exhausted either the list of possible cartographic projections or the full range of GMT's features. GMT comes with a lot more tools than just pscoast, but we'll have to refer you to the documentation at http://gmt.soest.hawaii.edu/ to learn what else it can do. We'll just finish by highlighting the psxy command from GMT, which plots longitude/latitude points in PostScript.

Given a list of the longitudes and latitudes of the world's 50 largest cities, separated by commas, one pair per line, in a file called cities.txt, we can use psxy to plot them on a Robinson projection of the world. The Robinson projection is a modified cylindrical projection, popular for balancing the trade-offs in size and shape on world maps. In this example, we'll plot the cities with .25 cm wide red stars and center the map at 10ºE, in order to avoid splitting Siberia. We'll leave further exploration of the following GMT commands as an exercise for the gentle reader, but you can see the map they produce in Figure 3-28:

\$ pscoast -JN10/18c -R-170/190/-90/90 -G64/255/128 -S64/128/255 -A5000 -K >
cities.ps
\$ psxy cities.txt -JN10/18c -R-170/190/-90/90 -Bg30/g15 -Sa.25c -G255/0/0 -O
>> cities.ps

Figure 3-28. The world's 50 largest cities, plotted on a Robinson projection

• [Hack #26]
• [Hack #29]
• [Hack #22]
• [Hack #31]