BUY THIS BOOK
Add to Cart

Print Book $29.95


Add to Cart

Print+PDF $38.94

Add to Cart

PDF $23.99

Safari Books Online

What is this?

Add to UK Cart

Print Book £20.95

What is this?

Looking to Reprint or License this content?


Mapping Hacks
Mapping Hacks Tips & Tools for Electronic Cartography By Schuyler Erle, Rich Gibson, Jo Walsh
June 2005
Pages: 564

Cover | Table of Contents | Colophon


Table of Contents

Chapter 1: Mapping Your Life
Fiction authors, when first starting out, are often advised to "write what you know." The same rule applies to telling stories with maps. If you are new to creating geographic narrative, we suggest looking to the nearby and the familiar for inspiration and information. As a result, our story begins with "Mapping Your Life."
The spatial rendition of your personal narrative can take many forms. Simply locating the important places in your life on a map, or identifying the highways and byways that lead to those places, can serve as a basis for geographic exploration. But telling your own story to others means being able to make your own maps, however simple and straightforward, of the places you live in or have visited. Going further, we can try to place other elements of our lives on a map, such as photographs of our adventures, in the hopes of bringing new life to the old tradition of vacation photo slideshows.
In this chapter, we've tried to focus on hacks that you can start experimenting with right away. For simplicity's sake, many of them are based on existing software or online services, but, as the book progresses, we'll try to show you how to get your hands dirty building these same basic tools and concepts on your own, with more complexity and expressiveness. Let's get started!
Your coordinates and their maps: online map services help you to tell your own story.
Plain geographic coordinates tell you where you are, but they don't tell you where you are in relation to your environment. Do you know where 39.5° North, 121.2° West is? Do you know what it is near? Providing this context is one of the basic uses for maps. There is nothing like adding a map to an email or web page to make the point that "wherever you go, there you are on the map." While this book is all about creating maps and doing geographical analysis, it can be hard simply to make a map on your desktop.
Fortunately http://mapquest.com, http://multimap.com, http://maps.yahoo.com, http://map24.com, and http://maporama.com all provide interfaces that allow you to put links to maps and driving directions on your own web page and in your emails. Map24 and Maporama offer free services, but since they require you to register with their site, this hack focuses on mapping arbitrary locations with MapQuest, Multimap, and Yahoo! using their free linking services, which are described at:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Hacks 1-13
Fiction authors, when first starting out, are often advised to "write what you know." The same rule applies to telling stories with maps. If you are new to creating geographic narrative, we suggest looking to the nearby and the familiar for inspiration and information. As a result, our story begins with "Mapping Your Life."
The spatial rendition of your personal narrative can take many forms. Simply locating the important places in your life on a map, or identifying the highways and byways that lead to those places, can serve as a basis for geographic exploration. But telling your own story to others means being able to make your own maps, however simple and straightforward, of the places you live in or have visited. Going further, we can try to place other elements of our lives on a map, such as photographs of our adventures, in the hopes of bringing new life to the old tradition of vacation photo slideshows.
In this chapter, we've tried to focus on hacks that you can start experimenting with right away. For simplicity's sake, many of them are based on existing software or online services, but, as the book progresses, we'll try to show you how to get your hands dirty building these same basic tools and concepts on your own, with more complexity and expressiveness. Let's get started!
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Put a Map on It: Mapping Arbitrary Locations with Online Services
Your coordinates and their maps: online map services help you to tell your own story.
Plain geographic coordinates tell you where you are, but they don't tell you where you are in relation to your environment. Do you know where 39.5° North, 121.2° West is? Do you know what it is near? Providing this context is one of the basic uses for maps. There is nothing like adding a map to an email or web page to make the point that "wherever you go, there you are on the map." While this book is all about creating maps and doing geographical analysis, it can be hard simply to make a map on your desktop.
Fortunately http://mapquest.com, http://multimap.com, http://maps.yahoo.com, http://map24.com, and http://maporama.com all provide interfaces that allow you to put links to maps and driving directions on your own web page and in your emails. Map24 and Maporama offer free services, but since they require you to register with their site, this hack focuses on mapping arbitrary locations with MapQuest, Multimap, and Yahoo! using their free linking services, which are described at:
Before you start creating hyperlinks to these free mapping services, familiarize yourself with their respective terms of use. If you abide by these terms, you are less likely to find this service taken down the next time you use your web application or when others visit your site and take a look at your work. Generally, the page you are linking to must not be displayed in a frame set. MapQuest also requires that the page you link to not be displayed in a new browser window. As these linking services are free of charge, banner advertising features on the web page you link to cover the cost of providing this service. Also, because of copyright restrictions, you are not permitted to download maps or store them locally.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Route Planning Online
Many map services offer a route planner. How do they work and why do they fail?
Maps not only assist you in indicating where you are now, but also help you plan where you want to go next. To help you out, most online mapping services such as Map24, Maporama, MapQuest, and Multimap feature a "driving directions" service on their web sites, which is free, online, and always available. These services provide directions in two different ways: they can give you driving instructions to a location you've just searched for on the site, or they can just help you plan a trip from point A to point B.
A typical route-planning session consists of four stages: address input and validation, address geocoding, route calculation, and route representation. The first two stages revolve around locating a given address in geographic space: translating a human-readable address into a machine-readable pair of coordinates. (You can see these principles in action in [Hack #79] .) Instead of worrying about just one address, two addresses must be converted into computer-friendly coordinates. In the third stage, the actual route is calculated. As this stage requires a lot of computer processing, it takes quite a while. In the last stage, the route is represented in a human-readable format as a table of textual instructions and additional information.
Road-network data that is used for route calculations is a subset of the data offered by commercial mapping data providers such as AND, GDT, NAVTEQ, and TeleAtlas. These data sets not only include representational information—the road class (to determine line width and line color), the road name, and house number ranges (for labeling)—but also navigational information.
To calculate the shortest or quickest route between two points, routing software borrows from graph theory and relies on (a variation of) the Dijkstra or A* algorithm. These algorithms take into account only the connectivity between navigable features and the difficulty (or impedance) factor of each navigable feature. When calculating the shortest route between two points over a network, the length of the navigable features is used as the impedance factor. When calculating the quickest route, the impedance factor incorporates both feature length and travel speed; the length of the navigable features is combined with their travel speeds to approximate the travel time for each feature.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Map the Places You've Visited
Sometimes a simple map showing the places you've been is all you need to start telling the story of your travels.
I've been everywhere, man,
I've been everywhere, man
Crossed the deserts bare, man
I've breathed the mountain air, man
Travel—I've had my share, man
I've been everywhere
Johnny Cash, "I've Been Everywhere"
In the U.S. and Canada, it's not uncommon to see camping vehicles or RVs sporting a map emblazoned on the side, showing the states and provinces that the vehicle has traveled through. And why not? For many of us, the list of countries we've been to, or the tally of states or provinces we've set foot in, is like a badge of honor, an encapsulation of all the adventures we've had and of all the wonderful places we've come upon in our travels.
Thanks to the miracles of modern technology, it's almost painless to make maps on the Web that highlight the places we've visited and proudly share those maps via web sites or email. A great place to start is World66.com, which describes itself as "the travel guide you write." Among the many cool features of the site is My World66, a page where you can make and export maps of places you've visited, including maps of the U.S., Canada, Europe, and the world. My World66 can be found at http://world66.com/myworld66/.
Start by clicking one of the "Visited Places" links, and you'll be taken to a page full of labeled checkboxes, each one corresponding to a place that can be shown on that map. Figure 1-4 shows some of the choices available for the "Visited States" map. Check all the places you've been to in that part of the world, and click "Generate Map." That's all there is to it! Figure 1-5 shows some of the states of the U.S. that Jo has visited.
Figure 1-4: Selecting states for the Visited States map
Figure 1-5: Jo hasn't quite been as many places as Johnny Cash, but she's working on it
What's especially hackish about these maps is how they are made: World66 doesn't redraw their maps from scratch each time someone visits their site. Instead, each map is stored in a
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Find Your House on an Aerial Photograph
"You Are Here" is a quick piece of wish fulfillment for the amateur cartographer.
The free Terraserver service (http://www.terraserver-usa.com/) offered by Microsoft provides a friendly interface for finding things and viewing base maps made from aerial photographs. Once upon a time, Terraserver covered the whole world on a large scale, but now it only republishes USGS maps for the United States The imagery can be as detailed as one-meter resolution—that's one meter per pixel, a pretty good resolution for aerial photography.
Terraserver provides many different ways to find what you're looking for. Follow the "Advanced Find" link on the left to find the different search options. You can search for an "Address," which Terraserver will attempt to geocode. If the geocoding works, you'll get a list of one or more likely matches from which to choose. It works similarly to the free geocoding service described in [Hack #79] .
You can also search for an identified "Place"—any spatial feature noticeable enough to be given a name by the U.S. Geological Survey. Terraserver will do a loose match from the beginning of the name you search for. In [Hack #85] , we describe how to use the freely available GNIS data to build a geocoded index of noticeable places.
If you know the latitude and longitude of your house or other interesting place, select the option "Geographic" from the lefthand menu and ask Terraserver to map the coordinates. You can enter either decimal degrees, which most geo applications prefer for ease of processing, or the older convention of degrees, minutes and seconds.
Figure 1-6 shows a sample Terraserver map: aerial photography from the USGS, showing the location of the O'Reilly Media offices in Sebastopol, California. Many of the free aerial photos are pretty old, though: as this was taken in 1993, it just shows the apple orchard where the O'Reilly campus is now.
Figure 1-6: Aerial photo of Gravenstein Highway
The Terraserver web site generates URLs for images that look like this:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
The Road Less Traveled by in MapQuest
The specified route may get you where you want to be, but what about that other road?
The interstates are fast and clean, but the Blue Highways are more than a routing choice. The motto of the Blue Line fan is "There is more than one way to get there." One morning I happened to stagger into life at 9:00 A.M., fretting about the coming day. I was in Portland, Oregon, at the O'Reilly Open Source Convention and wanted to get home to Sebastopol, California. The obvious and "simple" route is 656 miles down I-5, past Sebastopol, then a swoop up and around the San Francisco Bay and up 101.
Frankly, it is one of the prettier interstate drives around, but it is still an interstate drive. My car mates were lobbying hard for the purely scenic route along Highway 101. To make things a tad more complicated, we had to pick up yet another passenger in Eugene, Oregon. How much pain and time was that Blue Highway scenery going to cost me? I needed a way to quantify the tedium of the longer journey.
Everyone uses MapQuest to prepare monolithic routes, a single routing that describes the whole trip. I wanted to split that into segments and compare the time and distance of each segment. If you have connectivity, you can create multiple views of the same journey in MapQuest, or use the same techniques in any mapping service that provides directions. As an aside, the connectivity in Lithia Park in Ashland, Oregon, is stellar. The drive from Portland to Ashland is easy, so it is convenient to stop in Ashland to download a bunch of code to play with on the rest of the trip.
Picking alternative routes requires that we can see them! Since this trip is so long, we can't get enough detail to compare the I-5 and coastal alternatives on one map. The map in Figure 1-7 is useless for alternate route determination! In order to compare alternatives, we need to split our journey into at least two more detailed parts.
Figure 1-7: The scale is wrong, and no alternatives appear in the overview map
Here we can use the "Open in New Window" trick of most browsers. Navigate through MapQuest to a map that shows your complete trip and then right-click (Ctrl-click on the Mac) on the "+" sign of the Zoom tool that is along the right side of the map. In most browsers, this will open a right-click context menu that includes the option to open the link in a new window.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Make Route Maps Easier to Read
Trade in complex, hard-to-read maps produced by most online route-finding services for the clean, schematic maps of driving directions made with MSN's LineDrive.
Online route-finding services have, in some ways, revolutionized the task of plotting travel routes. Rather than bothering would-be hosts to tediously—and perhaps inaccurately—describe driving directions to their location by phone or email, the savvy Internet-connected automobile driver can simply say, "I'll just look it up on [insert your favorite online map service here]. Forty-five minutes, you say? See you then!" The sheer practical utility of such a tool has been the main driving force behind the development of most online, consumer-oriented mapping services.
The reality, however, is a bit uglier. Often, the maps produced by online route-finding services leave a bit to be desired. Figure 1-13 shows the map generated by MSN Maps & Directions (formerly MapBlast) to depict a driving route between the White House in Washington, DC, and Times Square in New York City. Although this map illustrates the broad sweep of the ideal course across the American landscape, it omits all of the actual details you need in order to avoid getting lost between points A and B. For that, you need to rely on the textual directions printed below the map, but these directions lose the whole sense of spatial illustration embodied by maps in general, and, what's more, the fine print can be awfully hard to read in a bouncing automobile.
Figure 1-13: A typical map of the route from the White House to Times Square
Two students from Stanford University, Maneesh Agrawala and Chris Stolte, noticed that hand-drawn route maps focus primarily on the names of roads, turning points, and the general direction of turns, while simplifying, distorting, or simply omitting other details, such as the length and shapes of roads and the exact angles of turns. Indeed, professional cartographers make use of these same techniques, collectively referred to as cartographic generalization , to make printed maps clearer and to emphasize their most important aspects. By contrast, online maps preserve every detail of a route, usually at the wrong scale, which means that shorter stretches at the beginning and end of a route often disappear relative to longer stretches in the middle. Furthermore, online map services, following the conventional "road atlas" paradigm, proceed to stuff the map full of all sorts of other details that might be relevant when planning a route, but that only get in the way when simply trying to follow a route. The result is worse than useless, because the driver of an automobile is often the navigator as well, and any map that requires more than a glance to extract crucial information can be a driving hazard.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Will the Kids Barf?
Compare road distance with straight-line distance to create an index of nausea.
As I'm blessed with a sweet but stomach-challenged boy, I'm often looking for routes that are less likely to trigger his "I need to throw up; where's your hat, Daddy?" reflex. The quickest way to trigger that impulse is to go too fast on a curvy road.
I originally developed my own little index of road curviness that I called the "quasi-fractal dimension" of a route. As it turns out, the professionals already have their own measure for this property, and our technical reviewer Edward Mac Gillavry set me straight.
In spatial analysis, the network deviousness is the discrepancy between the lengths of the actual routes in a network and the straight-line distance between the places linked up. For any pair of places on the network it can be measured by the detour index. The detour index is a measure of how directly movement may be made on a network. It is calculated as the ratio of the shortest actual route distance between a given pair of nodes and the direct, straight-line or geodesic distance between the same two points.
Detour index = shortest distance on a network between two 
points / direct distance * 100.
The minimum value of the index is 100, representing a direct route with no detour. High ratios suggest a weakly connected network but may also reflect the indirectness or deviousness of the individual routes connecting the nodes. The detour index is also referred to as the index of circuity or as the route factor.
So if the straight-line distance between two points is 20 miles, but the road distance is 25 miles, we get a detour index of 25/20 * 100 = 125. The road isn't curvy, honey; it's just devious.
The Transport Geography web page at http://www.geog.umontreal.ca/Geotrans/ defines the detour index as direct distance / road distance. According to this definition, the closer it is to 1, the more efficient the route. I prefer Edward's definition on purely esthetic grounds. When I'm calculating something called the "network deviousness" I want
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Publish Maps of Your Photos on the Web
Plotting the photos from your latest trip on a map used to be a chore, until now.
Many of us enjoy sharing experiences and photographs from our travels with our family, friends, and colleagues. A map can provide a better sense of a trip or experience by showing how the images are related both to each other and to the world. Yet it has always been a challenge to share our photographs on an actual map.
93 Photo Street is a novel photo-mapping tool from Transmutable that helps you to tell your story with maps. It makes publishing maps with photographs about as easy as publishing to your blog, by offering a completely menu-driven, drag-and-drop user interface for building and publishing maps to the Web, as well as a programmer API for those users who want to do more.
As of this writing, it can be downloaded for Windows 2000, XP, or Mac OS X 10.3 or higher for free under a Creative Commons license. You can find it on Transmutable's web site at http://transmutable.com/93PhotoStreet/.
The process of using 93 Photo Street is straightforward. The first step is to find a map to use as a backdrop. 93 Photo Street supports two kinds of maps. It supports detailed, although plain, street maps of the United States (using maps provided online by the U.S. Census "Tiger" project), and it supports using images, allowing you to pick any image file and use it as a backdrop.
In this case, I'd like to share my pictures from a vacation in Hawaii. Using a search engine, I can find a number of excellent base maps of Hawaii:
http://clusty.com/search?query=hawaii+map&v%3Aproject=clusty-images
http://images.google.com/images?q=hawaii+map
By saving one of the maps from these searches to my computer, I can import it into 93 Photo Street using the "Map → Import Map Image" menu item.
Next I open up my collection of photographs and drag my favorite photos from that vacation into 93 Photo Street. The photos then end up in a tray at the bottom of the screen. Although there is a File menu option to load photographs, I prefer to just drag and drop. Figure 1-17 shows a screenshot of this process.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Track the Friendly Skies with Sherlock
Use the Macintosh OS X search tool or a web browser to track flights.
It always seems to happen: you need to rush to the airport to pick someone up, but you don't even know if the flight is on time. You can go to http://www.flytecomm.com/cgi-bin/trackflight to use the "Track a Flight" service and locate flights in progress and show their position on a map. You can also access this service from Sherlock, the Macintosh search tool.
This doesn't supplant the simple act of calling the airline to get the flight status, but it is pretty cool to know that when they say the flight has been delayed two hours, what they really mean is that the flight has yet to leave the ground
Sherlock lives in the Applications folder. When the main screen appears, click on the "Flights" icon in the toolbar. You are then offered a search bar, shown in Figure 1-19, where you can search for the flight by airline, flight number, departure, or arrival city.
When flights are "en route," and the data is available, there is a check mark in the chart column.
Figure 1-19: Delta Flight 1598 en route to New York
The interface is seductive, the choices opulent, and the temptation is to spend far too much time exploring the nooks and crannies of the modern air transportation system. Please note this service covers only flights to the United States when they are within U.S. airspace.
This tool searches the flight status information provided by http://www.flytecomm.com, which offers "Real-time flight intelligence solutions" that include flight and weather details. An interesting note is that FlyteTrax uses two different map projections: the Lambert Conformal conic projection and the Mercator projection. Both projections are conformal, meaning that lines of constant direction are shown as straight lines (over small areas). This is an important characteristic for flight mapping. The Lambert Conformal conic projection corresponds to the map image of the United States and Canada with which most people are familiar.
Unfortunately, flights do not follow lines of constant direction. The shortest distance between two points is the great circle, which would be depicted as a curved line on a conformal projection. Because of great-circle routing, an aircraft flying long distances would not be on a straight line for most of the flight. The problem with this representation is that people could be easily misled into thinking that a particular flight they are following has a problem because it is not on the "straight line" between two cities.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Georeference Digital Photos
Have you ever looked at someone's photo album and wondered where the photos were taken? Using your GPS and digital camera, you can figure out just that, and it's easier than you think.
If your digital camera allows you to set the time, you can use tracklogs from your GPS to add latitude and longitude information to your digital pictures. Since every photo you take with your digital camera contains the time the photo was taken, your computer can use the time a picture was taken to look through the GPS tracklog to find out where you were when you took the photo. As long as the GPS is on and storing tracklogs while you take your photos, you can link the photos to their respective locations.
To start out, just like two robbers about to heist a bank, the digital camera and the GPS need to have their internal watches synced. Since the GPS picks up the current time whenever it locks onto a satellite, it will always be dead-on. The only problem with this method is that if you change time zones, you have to resync your camera's time, since the camera isn't quite as clever. Next, make sure your GPS has a lock on your location, and carry it with you as you photograph. See [Hack #58] for tricks on saving your tracklogs.
The GPS will record your tracks, giving you a record of your movement that can be later downloaded to your computer. Using the common bit of information, the timestamp, various programs can match up the photos to their respective locations. For the PC, there is Microsoft's free World Wide Media Exchange (WWMX, available at http://www.wwmx.org/), RoboPhoto ($35, at http://robophoto.com), RoboGeo ($22.95, at http://robogeo.com), Quakemap ($10, at http://www.earthquakemap.com/), and TopoFusion ($40, at http://www.topofusion.com/). You can also use purely web-based services such as GeoSnapper.com or Thingster.com.
Alternatively, and for less than $950 USD, you can get a camera that will do the linking for you. These cameras have built-in GPS receivers or have GPS attachments. As of this writing, you can purchase the older 1.4 mp Kodak DSC 260 series, the costly Nikon DSLR cameras (D1x, D1h, Pro 14n, and Pro SLR/n), or the impressive new Ricoh "Caplio Pro G3" with GPS card. With the cost of GPS chipsets decreasing, more cameras, and even camera phones, are getting into the act. Already the Japanese AU camera phone can take georeferenced images, and other Japanese camera manufacturers are adding GPS to attract new patrons. U.S. camera phones are enabled to find your location in case you call 911, so I hope next year's smart phones will start including this feature.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
How Far? How Fast? Geo-Enabling Your Spreadsheet
How far did I go? How long did it take to get there? Calculating speeds and distances by working with geodata in Excel.
Wouldn't it be great if you could ask what-if questions of your geodata? Questions like "How far did I go on that trip?" or "What was my average speed from Tuscan to Tucumcari compared with the leg from Tehachapi to Tonopah?" A geo-enabled spreadsheet is your willing companion on this journey.
It once happened that I was trapped in a hotel with no connectivity. I had GRASS [Hack #69] on one laptop and lots of tracklogs of our wanderings through Disneyland on another laptop, and no way to get tracklogs from one computer to another. Fortunately, I had a copy of Microsoft Excel on the same computer as the tracklogs. And when all you have is a spreadsheet, then everything looks like rows and columns. As it turns out, tracklogs and waypoints naturally fit into the spreadsheet metaphor. I was able to cobble together an ugly spreadsheet analyzing our trip, but I longed for something more, dare I say, elegant?
I later learned that Jeff Laake of the National Oceanic and Atmospheric Administration faced similar challenges in his work studying marine mammals. He created a set of Visual Basic for Applications macros to add basic geospatial functions to Excel. With Jeff's library, you can turn your spreadsheet into a monster geospatial data processing engine.
I've incorporated Jeff's geofunc.xla , with minor extensions, into a sample spreadsheet with examples of the use of most of the functions. Download it at http://www.mappinghacks.com/data/spreadsheet/geodata_sample.xls. The original library, and more explanations of the functions, lives at: http://nmml.afsc.noaa.gov/Software/ExcelGeoFunctions/excelgeofunc.htm.
The first worksheet, labeled Function Examples, demonstrates the use of the library functions. My favorite function is posDist(), or position distance, which is shown in Figure 1-20. This returns the distance in nautical miles between two locations.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Create a Distance Grid in Excel
Create tables showing the distance and bearing between pairs of points, using a simple add-in library for Excel.
Creak out of the car, road blurred eyes, accelerator stiffened joints, then wander dazed to the large grid that shows you at "Forgotten Rest Area #17" and the distance to anywhere you'd want to be. The joy of gas station city-distance grids! Look down the left column for "Where I am" and across to find "The promised end of the trip," and read the measure of your pain. Now all the fun and excitement can be yours again, in the comfort of your very own home!
Start by downloading http://www.mappinghacks.com/data/spreadsheet/sample.xls, as described in [Hack #11] . The sheet labeled train grid, shown in Figure 1-23, depicts a sample distance grid for a set of waypoints of train stations at Disneyland. The grid shows the straight-line distance between any two points in yards. Look down column B and locate the Main Gate in cell B24, then move across to column G and read the distance from the Main Gate to the Tomorrowland train station, which is 445 yards.
Figure 1-23: The distance between train stations at Disneyland
The distance grid represents the "as the crow flies" distance. Calculating road distance requires routing algorithms and databases that are beyond the scope of this hack.
The train grid sheet also includes a bearing grid to show your straight-line course from point to point. Remember your mnemonics of direction: Never (North, 0 degrees) Eat (East, 90 degrees) Smelly (South, 180 degrees) Worms (West, 270 degrees) (or "Never Eat Sour Watermelons").
Take a look at the next worksheet, labeled equator grid, as shown in Figure 1-24. This is the same basic table, but this one shows the distance and direction within one degree of the equator and the prime meridian: from (0, 0) to (1N, 0), (1S, 0), (0, 1W), (0, 1E), (1N, 1E), and (1S, 1W). This sheet displays distances in statute miles, as opposed to yards. The conversion factor is set in the cell labeled conversion_factor
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Add Maps to Excel Spreadsheets with MapPoint
If you have both Microsoft Excel and Microsoft MapPoint, you can add maps to your spreadsheets with a few clicks.
A lot of people manage address lists and other address-based data in Microsoft Excel, but while Excel provides all kinds of graphing capabilities, it doesn't know much about maps. If you add Microsoft MapPoint to your system (another $250, admittedly), you can show your Excel data on a map quite easily.
As the November 2004 election is coming up as I'm writing this, I've been doing a lot of work with voter registration rolls. One of my spreadsheets, actually an export from Access, is a list of street addresses and party affiliations, as shown in Figure 1-28.
Figure 1-28: An address-laden Excel spreadsheet
Because MapPoint 2004 is installed on the same computer, Excel shows an extra toolbar button to the left of the font-choice drop-down box. Clicking on that button inserts a MapPoint object on the spreadsheet and also starts up the Link Data Wizard, shown in Figure 1-29. (If you have more than one area of data on the spreadsheet, select the part you want to map before clicking the button.)
Figure 1-29: The Link Data Wizard's initial interpretation of the address data
MapPoint will make an educated guess about data types based on headers in the document, and you can use the drop-down boxes to correct it if it's wrong. MapPoint will accept a variety of geographic data types, varying by country. For the United States, it accepts any three of address, city, county, state, country/region, ZIP Code, three-digit ZIP Code, census tract, metropolitan area, latitude, and longitude. Once you've chosen the correct data types, MapPoint will ask to identify a primary key, as shown in Figure 1-30.
Figure 1-30: Choosing a primary key in the Link Data Wizard
If all you plan to plot is the one area currently being examined, you don't really need a primary key. If, however, you're combining multiple sets of data, such as customer addresses and customer spending amounts, you'll want something like a customer ID number to act as your primary key connecting the data.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Chapter 2: Mapping Your Neighborhood
Stand in the place where you live
(Now face north)
Think about direction
Wonder why you haven't before
REM, "Stand"
Beyond the scope of our own lives, we find the past, present, and future of the places we inhabit and the other people that inhabit them. Maps offer the chance to tell new narratives about familiar places. From health code violations to campaign contributions, from demographic models to elevation models, our immediate environment is awash in geographic detail, waiting to be shown on a map and its stories told to the world. In this chapter, we explore the dimensions that "Mapping Your Neighborhood" can take on.
The U.S. Census Bureau's TIGER Map Server isn't fast or fancy, but the maps it makes are free and entirely hackable.
Although the maps made by MapQuest, map24.com, and other commercial mapping services are nice looking, fast, and reasonably effective, their use is severely limited by their licensing terms. What's more, you can't easily map your own data on top of the digital maps these services produce. However, in the United States, we enjoy a remarkable plethora of public-domain geographic data, much of it in the form of the Census Bureau's TIGER/Line data set, which the Bureau uses as the basis for the TIGER Map Server, a free web-based mapping service, covering the entire United States. You can browse their maps manually, or programmatically generate unencumbered, public-domain maps through their service for your own purposes. We'll look at both of these uses of the TIGER Map Server.
The TIGER/Line data set, which the Census Bureau updates annually, contains vector data about streets, highways, waterways, political boundaries, parks, metropolitan areas, and more, all collected as part of the Bureau's mission to enumerate the population of the United States to ensure the fair apportionment of federal congressional districts. Blessedly, the Bureau publishes the raw TIGER/Line data for free, all several dozen gigabytes of it, already collected at taxpayer expense, on the Census Bureau web site for anyone to download and make use of. In doing so, they set a shining example to the rest of the world of what it means for government to provide and support a national geographic data infrastructure.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Hacks 14-21
Stand in the place where you live
(Now face north)
Think about direction
Wonder why you haven't before
REM, "Stand"
Beyond the scope of our own lives, we find the past, present, and future of the places we inhabit and the other people that inhabit them. Maps offer the chance to tell new narratives about familiar places. From health code violations to campaign contributions, from demographic models to elevation models, our immediate environment is awash in geographic detail, waiting to be shown on a map and its stories told to the world. In this chapter, we explore the dimensions that "Mapping Your Neighborhood" can take on.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Make Free Maps of the United States Online
The U.S. Census Bureau's TIGER Map Server isn't fast or fancy, but the maps it makes are free and entirely hackable.
Although the maps made by MapQuest, map24.com, and other commercial mapping services are nice looking, fast, and reasonably effective, their use is severely limited by their licensing terms. What's more, you can't easily map your own data on top of the digital maps these services produce. However, in the United States, we enjoy a remarkable plethora of public-domain geographic data, much of it in the form of the Census Bureau's TIGER/Line data set, which the Bureau uses as the basis for the TIGER Map Server, a free web-based mapping service, covering the entire United States. You can browse their maps manually, or programmatically generate unencumbered, public-domain maps through their service for your own purposes. We'll look at both of these uses of the TIGER Map Server.
The TIGER/Line data set, which the Census Bureau updates annually, contains vector data about streets, highways, waterways, political boundaries, parks, metropolitan areas, and more, all collected as part of the Bureau's mission to enumerate the population of the United States to ensure the fair apportionment of federal congressional districts. Blessedly, the Bureau publishes the raw TIGER/Line data for free, all several dozen gigabytes of it, already collected at taxpayer expense, on the Census Bureau web site for anyone to download and make use of. In doing so, they set a shining example to the rest of the world of what it means for government to provide and support a national geographic data infrastructure.
The TIGER Map Server Browser lives at http://tiger.census.gov/cgi-bin/mapsurfer. With no other options supplied to it, the Browser loads a map of Washington, DC, by default. Included are the usual web-based map interface buttons for panning and zooming, and, on the upper right, a set of radio buttons selects the action that's taken when the map is clicked on. While the zoom in, zoom out, and recenter commands are pretty standard for an online map service, that's where the similarity to other such services ends. The next two commands allow you to put a marker of your choice anywhere on the map with a click and then download a GIF image of the map you've created. Further down the right side, you can select precisely which features you want displayed on the map. Let's see you do that, MapQuest! Figure 2-1 shows the basic web interface to the TIGER Map Server.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Zoom Right In on Your Neighborhood
And thereby give new meaning to the term "ICBM coordinates."
I like pretty pictures that move. Sadly, most maps are stable and don't move. Biologists have a special word for systems that are stable and no longer move, and that word is "dead." Let's get the defibrillation paddles out and put some life into our maps. [Hack #1] describes how to find a location using MapQuest, and it will get you a map. But where is the place described by that map? My daughter wanted to know where New Orleans is. She went to MapQuest and searched. And MapQuest presented exactly what she asked for. Try it! The city appears on the banks of Lake Ponchartrain. But where the heck is that? Molly zoomed out, and out, and out, until Texas appeared. "Ah, I see now where it is."
To save her from the effort of ever again clicking "zoom out" three times in rapid succession, I wrote a little script called boomzoom.cgi . I called it this, because the first person who saw it said that it looked like the earth as viewed from a rapidly approaching ICBM. Now, as it turns out, my friend wasn't all that far off: Cartographers actually have a term for this kind of instant zoom-in orientation, which they call ballistic navigation . But somehow "boomzoom" was the name that stuck for me.
You can run it at http://www.mappinghacks.com/cgi-bin/boomzoom.cgi. Enter the latitude, longitude, and text to mark your center point, and then select "Make zoomy thing," as shown in Figure 2-6.
Figure 2-6: Boomzoom's initial screen
The Boomzoom program proceeds to fetch about 10 images from the TIGER Map Server [Hack #14] , and then stitches them together to make an animated GIF. Each image is shown for just long enough to give an idea of what it is showing, before giving way to the next. Figure 2-7 shows the first image of a "boomzoom" on the O'Reilly campus in Sebastopol, CA.
Figure 2-7: Can you find O'Reilly?
You can run the same basic code on your desktop, as well. Since the TIGER data allows us to grab map images directly, we can automate the process with this bit of Perl, which we'll just call
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Who Are the Neighbors Voting For?
Fundrace can show you which political candidates and parties have the most support in your area—and which of your neighbors are supporting them.
The financial machinations of presidential election campaigns are not as distant, highbrow, or incomprehensible as one might think, and the web site http://www.fundrace.org/ will show you why. Enter your address and ZIP Code into its Neighbor Search, as shown in Figure 2-8, and you are immediately provided with a vista of the political landscape of your neighborhood. By aggregating and geocoding campaign contribution records, Fundrace allows you to uncover a little more about the pocket depth and political sentiment of your friends, coworkers, relatives, and neighbors.
Figure 2-8: A Fundrace Neighbor Search
Fundrace is the result of questions asked and hacks committed by researchers working at Eyebeam (http://eyebeam.org/), a nonprofit, nonpartisan arts and technology organization in New York City. Fundrace is built on a database of presidential campaign finance records published by the United States Federal Election Commission (FEC). These records include the amount and date of each contribution totaling over $200, along with the name, mailing address, occupation, and employer of the corresponding contributor. With individual contributions to campaigns capped at $2,000, and campaigns raising tens of millions of dollars at a stroke, this amounts to a fair heap of information for anyone to try to interpret meaningfully.
In the autumn of 2003, the financing of the presidential primary campaigns, especially those using grassroots fundraising over the Web, was a prevalent topic in the national media. The content and presentation style of other existing campaign finance web sites, such as http://www.opensecrets.org/ and http://www.fecinfo.com/, did not seem likely to attract the attention of anyone who wasn't actively seeking out this information already. The first iteration of Fundrace consisted of a number of simple statistical rankings and a handful of national fundraising maps, intended to help people draw some distinctions among the wide field of candidates running at the time.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Map Nearby Wi-Fi Hotspots
Create interesting and useful maps of local and international Wi-Fi hotspot coverage.
Ever wonder how you can track the wireless networks in your neighborhood, or near your office—or how you can find free wireless connectivity when you're away from your home and office? I wondered the same thing, and so with the help of Eric Blevins, we created http://www.WiFiMaps.com for exactly this purpose.
WiFiMaps.com is a web-based, interactive map of wireless networks, with detailed street-level maps. If you're looking for open Wi-Fi nodes nearby, you can use the web site to browse geographical areas, perform various types of searches, and compare location or user statistics. The wireless node data is kept up to date by users who upload their wardriving data. Figure 2-11 shows a map of some of the Wi-Fi hotspots found in California, made with data contributed to WiFiMaps.com.
Figure 2-11: Wi-Fi hotspots in California
Wardriving is the geek sport of driving about (or walking, or biking, or even flying) while searching for wireless networks. The idea is to connect a GPS and wireless card to your portable computer, hop in the car, fire up your favorite wardriving program, and go out for a drive. As you move, the GPS records your location and some of the parameters of what your wireless card hears. The software on your portable computer takes note of the GPS coordinates and signal strength, and it usually beeps when a new network is found.
The term wardriving hearkens back to the script kiddie practice of wardialing, where a computer automatically dials phone numbers sequentially, looking for computer networks to crack into. Don't be misled by the aggressive sound of the term, however. The practice of wardriving can be carried out on an entirely passive—and legitimate—basis.
Mapping wireless networks can reveal patterns that are not always obvious. In the Wi-Fi map of California (Figure 2-11), we see the expected concentration of networks mirroring the populated parts of the state, but we also see the string of networks down the main highways.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Why You Can't Watch Broadcast TV
Find out why radio and TV reception can be poor, even if you're near a broadcast tower.
Do not adjust your set! Fiddling with that dial may do your crackly reception no good at all. Much like Wi-Fi, broadcast television signals need a clear line of sight for transmission and can be blocked by hills or other large obstructions. In this hack, we'll use a free software application for *NIX called SPLAT! to explain why you can—or can't—watch your favorite broadcast TV station where you live.
According to its web site, SPLAT! is a "terrestrial RF path analysis application for Linux/Unix." Radio frequency path analysis models how radio signals travel over different terrains to figure out how far a radio signal can reach. This technique gives reasonable estimates for the spectrum between 20 MHz and 20 Ghz: from FM radio to satellite-based microwaves. Using SPLAT! we can work out coverage areas for FM radio, television, and even Wi-Fi [Hack #17] , but not AM or shortwave radio. (At lower frequencies, these kinds of radio signals bounce off the underside of Earth's ionosphere. This is why lower frequency radio can travel a long way, but it's harder to estimate how far away that may be.)
SPLAT! relies on the 1:250k digital elevation models provided for free by the U.S. Geological Survey, making it only useful for plotting radio and television reception in the United States. Fortunately, GRASS, that Swiss Army chainsaw of free GIS tools, can be persuaded to plot line-of-sight viewsheds using any terrain data [Hack #74] .
You can download SPLAT! from its homepage at http://www.qsl.net/kd2bd/splat.html. Grab the latest tarball, which as of this writing was splat-1.1.0.tar.gz, and unpack and build it as follows. The SPLAT! application and utilities will install under /usr/local by default:
# tar zvfx splat-1.1.0.tar.gz
# cd splat-1.1.0
# ./configure
# ./install all
You'll need to make sure you have the zlib and bzip2 development libraries installed on your system in order to build SPLAT! correctly. On Debian Linux, try
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Analyze Elevation Profiles for Wireless Community Networks
A web application and a few digital elevation models can significantly ease the pain of building wireless community networks in remote areas.
If you're trying to build wireless community networks out in the hills, like the NoCat Network has done in Sonoma County, California, the first thing you discover is that hills eat Wi-Fi signals for lunch. Modern wireless networking technologies, like 802.11b, need a line of sight to establish a connection, and any significant amount of intervening terrain, trees, or buildings between two points will quickly ruin your chances of setting up a long-distance, point-to-point wireless connection. In places where DSL and cable are unavailable, however, point-to-point community wireless links are often the only way that local residents can get high-speed Internet connectivity, so there's often a lot of motivation to find ways to work with the surrounding terrain.
Naturally, the first question a newbie asks when he shows up at a community network meeting is, "Can I get on the network?" The answer is, inevitably, "That depends. Where do you live?" Armed with the GPS coordinates of the newbie's house, you can do a certain amount of terrain analysis using digital elevation models (DEMs) in commercial software like TopoUSA or free software like GRASS. The downside to this is that, if you have 50 would-be participants in a community network, then the total number of possible links to evaluate is, apropos of nothing else, 50 x 49 2 = 1225. That's a lot of work to do by hand!
There had to be a better way. Our ambition was to create a tool that would allow a community member to get their house on the NoCat Network with nothing more than a compass and a Wi-Fi card with a high-gain antenna. We demonstrated that, using GRASS, we could extract elevations from 10-meter-resolution USGS DEMs along the line connecting two locations and use them to plot a contour profile with Perl and the GD::Graph module from the CPAN. If the elevation of the straight line in three dimensions between those two points is less than or equal to the elevation at any point along that line, then there's a hill in the way, and a link probably won't be feasible. If the elevation of the line of sight is above ground elevation along the whole distance, then a wireless connection might be possible (but see the caveats mentioned later in this hack).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Make 3-D Raytraced Terrain Models
Convert digital elevation models into exciting scenes of rendered terrain, using the free raytracer POV-Ray.
The free topographical map data from the USGS makes a fine candidate for creating three-dimensional scenes of territory. The POV-Ray 3-D raytracer allows you to easily import any image for use as a height field in creating a scene with a ground terrain. POV-Ray is available in source code form, and you can get binaries for Linux, OS X, and Windows from http://povray.org/.
POV-Ray has a bit of a reputation for its steep learning curve, but we're not going to do anything terribly complicated with it. We can feed it an image file to use as a height field, with simple parameters that control its display. Once we've done that, we can drape satellite or aerial imagery over the raytraced terrain model, to give it a realistic look. The only really tricky bits are getting the digital elevation models into an image format that POV-Ray likes and orienting the satellite imagery so that it matches the underlying height field.
We picked Crater Lake, a lake formed in the caldera of an enormous and ancient volcano in Oregon, to render in our example, because it's a very distinctive-looking terrain feature. If you're in the U.S., you can get data from the USGS Seamless Data Distribution System [Hack #67] at http://seamless.usgs.gov/. We elected to download both the 1" National Elevation Data (NED) as well as the Landsat composite imagery for the area surrounding Crater Lake. Then we drew a box around the lake on the map using the area-download tool, and we were given a pop-up window allowing us to download both files. Make sure that the border of your download selection box stays green!
If you're outside the United States, SRTM data for the whole world at 90m resolution is theoretically available from NASA, as well as ground imagery, including Landsat and MODIS data. The Global Land Cover Facility at http://glcf.umiacs.umd.edu/ is a good place to look for this sort of data, as is the GLOBE Project at
<