.NODE

Hack 32. Hack on Base Maps in Your Favorite Image Editor

You don't always have to rely on complicated GIS software to make maps that tell your story. In fact, sometimes it's a lot easier not to.

While writing [Hack #29], we had the chance to explore the flatplanet catalog of free world maps, which can be found online at http://flatplanet.sourceforge.net/maps/. This collection offers world maps based on satellite imagery, topography, temperature, rainfall, land use, demographics, plate tectonics, and more, but not a single map featuring political boundaries. (Actually, the population growth map shows political boundaries, but it also completely omits places for which no data was availablee.g., Greenland, Western Sahara, Eritrea, et al.)

Although we are philosophically opposed to the social and economic inequalities that political borders serve to maintain and foster, there is no denying that the same political borders offer a very immediate source of context to the stories we can tell with maps. From a storytelling context, borders offer a way of breaking up huge landmasses into smaller places that people have heard of, and maybe know something about. Wouldn't it be nice to have some of this lovely Earth imagery show international boundaries, as a way of offering more context to the other things we'd like to display on a world map?

At this point, a professional digital cartographer might reach for his GIS software and start loading vector layers, but we wanted something easier. For starters, where to get a decent vector layer that represents the world's current set of political borders and isn't encumbered by licensing restrictions? One easy answer is the Generic Mapping Tools, or GMT, which includes a free, reasonably current set of international-boundary vectors at a reasonable resolution. GMT is covered in great detail in [Hack #28] . For now, we'll simply assume you have it installed.

GMT outputs its maps in PostScript, which makes good sense for a software package whose original purpose in life was to help scientists make maps for publications. However, even though it can be used to draw very precise vector maps, PostScript is not particularly renowned as a common GIS format. Many image editors, on the other hand, can work with PostScript just fine, including our favorite, the GIMP. The same image editors also have no trouble with the JPEG images available from the flatplanet project. So why not use them to make new maps? Let's walk through what we did to add political borders to the Blue Marble map of Earth.

3.12.1. Drawing the Political Boundary Layer

Let's start by generating the political-borders layer in PostScript using the pscoast command from GMT, as follows:

$ pscoast -JQ0/11i -R-180/180/-90/90 -N1/3 -A4000/0/2 > world.ps

The -JQ0/11 option to pscoast tells it that we want an Equidistant Cylindrical projection of the world to match the projection used in the flatplanet maps, centered on the prime meridian (i.e., 0 degrees longitude), plotted 11 inches wide, which is the largest size page that the GIMP will import. -R-180/180/-90/90 asks pscoast for a map of the whole world. The -N option tells it to draw political boundaries. In this case, we want just the international borders, drawn with a three-pixel-wide pen. Note that we're not asking pscoast to draw coastlines, or fill any of the shapes, because we will want to see coastlines and landmass details from our underlying JPEG base map instead.

Finally, -A4000/0/2 filters pscoast's vector database in such a way that features less than 4,000 km2 in area, or more than two levels down hierarchically (out of a total of four levels), are omitted. You'll want to refer to the GMT documentation for further clarification on how this works, but our particular selection ensures that most nations and large lakes are included, but small islands, smaller lakes, and rivers will be excluded. Without specifying -A, we get everything in the vector database that ships with GMT, which is quite a lot, and really too much detail for the scale of the map we want to draw.

The pen size and feature filter size that we fed into GMT were chosen mostly through trial and error to fit our example. There's not much science to this; if you need to make a map for a larger or smaller scale, then you may want to play with these values a bit to get the final map to look the way you want. We did say it was a hack!

Figure 3-36 shows the output from pscoast. It's kind of interesting to see just how much of the world's political boundaries are formed by the shapes of the planet's coastlines. You might notice, for example, that New Zealand and bits of eastern Siberia are missing from the image; that's because there are no land boundaries in that part of the world!

Figure 3-36. The world's political borders, as generated by GMT

 

3.12.2. Importing the Map Layers

Now, let's switch to our image editor. We like the GIMP, but any advanced image editorlike Photoshop, for examplewill have all of the features and tools we describe. First, grab the image you want to overlay the political boundaries on. We chose the 2048x1024 pixel Blue Marble image from http://flatplanet.sourceforge.net/maps/natural.html, but any of the images on that page will do. You can also find a copy of this image at http://mappinghacks.com/maps/land_shallow_topo_2048.jpg. Save it to your hard drive, and load it up in your image editor. This image will serve as the base layer, over which we'll drape the boundaries layer. Figure 3-37 shows what this image looks like.

Figure 3-37. NASA's Blue Marble map of Earth

Next, we'll import the boundaries layer, which we saved earlier as world.ps. Loading a PostScript file will trigger a dialog that provides the image editor with some hints about how to rasterize the vector data. In the GIMP, PostScript files always load in portrait orientation at 8.5"x11", so the resolution we select influences how many pixels wide and high the imported image will be. We want to select a resolution that will make the two images come out the same size. Since our underlying JPEG image is 2048 pixels wide, we need to divide 2048 pixels by 11 inches to get a resolution of around 186 dots per inch (dpi), which will make the two images more or less match. At this resolution, the boundary layer becomes 2046 pixels wide, which is close enough.

The PostScript import dialog in the GIMP also offers anti-aliasing options. Anti-aliasing fuzzes out the curves and corners in the rasterized version of the vector drawing, so we don't end up with jagged-looking edges. We opted for high graphical anti-aliasing for our boundary layer, but you might want to tweak this setting to see what you end up with. You should now have two different images loaded, one of the satellite imagery and another of the political boundaries.

3.12.3. Combining the Layers to Make a New Map

The first thing you'll notice about the boundary layerin the GIMP, anywayis that it's lying on its side! That's because GMT produces landscape-oriented PostScript by default, but the GIMP assumes that all PostScript is portrait-oriented. So the first thing to do is to correct this, by clicking on the boundary layer, and then selecting "Image images/ent/U2192.GIF border=0> Transform images/ent/U2192.GIF border=0> Rotate 90 degrees CW" from the drop-down menu. This should rotate the image such that it's now oriented correctly. Now execute Edit images/ent/U2192.GIF border=0> Selection images/ent/U2192.GIF border=0> Select All to select the entire image, and then Edit images/ent/U2192.GIF border=0> Copy to copy it to the clipboard.

Next, click on the Blue Marble image and run Edit images/ent/U2192.GIF border=0> Paste to paste the boundary image in as a floating layer, which should make the Blue Marble image disappear beneath it. We need to alter the opacity of the boundary layer so that the white parts become transparent, leaving only the black borders. In the GIMP, you can go to Tools images/ent/U2192.GIF border=0> Layer Dialog, which pops up a dialog displaying both layers of the current image. Click on the upper of the two, which should be the floating layer containing our political boundaries. Then click the drop-down menu labeled Opacity, and change it from Normal to Multiply. Suddenly, the white background of the boundary layer disappears, and the topographic map of Earth reappears beneath it!

The last thing we need to fix is that the boundary layer is probably in the wrong place with respect to the Blue Marble image underneath. Select the Move tool from the toolbox (or hit the M key in the GIMP), and you should be able to drag the political boundary layer around over the top of the topographic map. You should be able to drag the boundaries almost into place with the mouse; then zoom in and nudge the image with your arrow keys, until the upper layer falls into place. The last couple of pixels might be a little challenging, so try zooming in on a region that you're really familiar with for this part. We chose the area around Michigan and Ontario as a good place for aligning the two layers, because the border there conforms pretty closely to the shape of the land and lake areas. Finally, hit the Anchor Layer button on the Layer dialog, and you're done! Figure 3-38 shows the two layers, aligned and merged. You can find a copy of this map image online at http://mappinghacks.com/maps/ for use in your own projects.

Figure 3-38. Our new political map of the world, using NASA's Blue Marble imagery and international boundary vectors from GMT

Now, a GIS expert might be horrified at this approach, but you're not going to be using this map for oil drilling or disaster relief, are you? When you're telling stories with maps, and precision is not a great concern, there's nothing wrong with using the tools you have at hand.

3.12.4. See Also

  • [Hack #28]
  • [Hack #29]

Mapping Your Life

Mapping Your Neighborhood

Mapping Your World

Mapping (on) the Web

Mapping with Gadgets

Mapping on Your Desktop

Names and Places

Building the Geospatial Web

Mapping with Other People

show all menu





Mapping Hacks
Mapping Hacks: Tips & Tools for Electronic Cartography
ISBN: 0596007035
EAN: 2147483647
Year: 2004
Pages: 172
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net