Hack 14. 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.

 

2.2.1. Browsing the Web Interface

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.

Figure 2-1. The basic web interface to the TIGER Map Server

That's just for starters, though. If you scroll down the page, you'll see form elements that allow you to request a map centered at a particular latitude and longitude, or one based on a search for a particular location or ZIP code. Additionally, there's an interface that allows you to select a particular graphical marker from a lista ball, pin, or other iconand place it on the map, either by selecting the appropriate radio button at the top and then clicking on the map, or by entering latitude and longitude coordinates. There's also a form field that allows you to add a label to the marker. Figure 2-2 shows a TIGER Map Server map of downtown Washington, DC, with a blue pin identifying the Lincoln Memorial.

Figure 2-2. The Lincoln Memorial, as shown by the TIGER Map Server

Now, this may not be the finest map you've ever seen, from the standpoint of cartographic design, but it already scores over many other mapping services in two important respects. First, you can do whatever the heck you want with itthese maps are in the public domain. Second, you can plot your own stuff on it. These maps can help tell your story.

2.2.2. Mapping a List of Points

It gets even better. What if you want to display more than one marker on the map at a time? See the text field labeled Marker URL? It turns out that if you make a list of waypoints, you can put it on the Web somewhere and use the Marker URL field to tell the TIGER server to fetch it and map it. Here are the first six entries in a list of geysers in Yellowstone National Park, taken from the GNIS [Hack #85] and rendered in the TIGER Map Server's ad hoc Marker URL "format":

# Excerpted list of GNIS geyser features from Park County, WY
-110.4347,44.6203:red5:Black Dragons Cauldron
-110.6833,44.7000:red5:Fearless
-110.8167,44.7167:red5:Jet
-110.7528,44.6833:red5:Monument
-110.4333,44.6247:red5:Mud Volcano
-110.7067,44.7056:red5:Porkchop

The first line is a comment, as indicated by the hash mark (#) at the beginning of the line. For the remainder of the file, each line is a waypoint, with three colon-separated fields. The first field is longitude, latitude, separated by a comma. The next field is the marker type, which we'll get into more detail about in a minute. Finally, the last field is just the name of the waypoint. This particular file contains a total of nine entries. If we post the file at http://mappinghacks.com/data/geysers.txt, we can put that URL into the TIGER Map Server web form, set the latitude and longitude to something appropriate, and hit "Redraw Map." The result looks something like Figure 2-3.

Figure 2-3. Some Yellowstone geysers, mapped via Marker URL

Remember that many, if not most, online mapping applications expect longitudes west of the prime meridian and latitudes south of the equator to be negative values. Also, don't forget that the Marker URL format puts longitude and not latitude firstbecause longitude is actually the x-coordinate.

 

2.2.3. Hacking the Hack

The best part about the TIGER mapping service is that you don't have to use their web interface to make maps; you can automatically generate them by crafting a custom TIGER Map Server URL that specifies the details for the map you want. The map image, which is rendered in a simple sinusoidal projection, is then returned in GIF format. The request URL takes the following basic form:

http://tiger.census.gov/cgi-bin/mapgen?param=value¶m=value&...

The types of parameters available for direct request are in essence the same as those used in the web interface. For example, this URL will generate a nice, simple map of Lower Manhattan in New York City, which is shown in Figure 2-4:

http://tiger.census.gov/cgi-bin/mapgen?lat=40.739&lon=
-73.99&wid=0.06&ht=0.08&iwd=480&iht=640

Figure 2-4. A map of Lower Manhattan generated by direct request

The lat and lon parameters specify latitude and longitude, respectively, in decimal degrees. The wid and ht parameters specify the width and height of the maps in decimal degrees, while iwd and iht parameters specify the width and height of the desired map in pixels. So the map in Figure 2-4 should come out 480 pixels wide by 640 pixels high. If the aspect ratio specified by iwd and iht is different from that specified by wid and htand remember that, in the continental U.S., a degree of latitude is about 1.5 times longer than a degree of longitudethen the map coverage may come out a little differently than requested, but that shouldn't ordinarily present a problem.

The TIGER Map Service supports a whole lot of other tweakable parameters. Table 2-1 lists some of them. See the TIGER Map Service instructions page at http://tiger.census.gov/instruct.html for exact details.

Table 2-1. Some useful TIGER Map Server direct request parameters

Parameter

Description

Notes

lat

Latitude of the map center in decimal degrees

Values for the continental U.S. range from around -125 to -67.

lon

Longitude of map center in decimal degrees

Values for the continental U.S. range from around 24 to 49

wid

Width of map coverage in decimal degrees

1º of longitude = ~55 mi at 24º N, ~40 mi at 49º N

ht

Height of map coverage in decimal degrees

1º of latitude = ~60 mi or 100 km

iwd

Width of map image in pixels

Defaults to 512 pixels

iht

Height of map image in pixels

Defaults to 256 pixels

legend

Show map legend instead

If set to on, the map legend is returned in place of the map.

mark

Map marker locations, in format lon,lat,marker;lon,lat,marker;...

See http://tiger.census.gov/instruct.html for a complete list of marker types

murl

URL to a list of map markers to display

See Section 2.2.2 for details about the marker file format

on

Explicitly include certain map features

See http://tiger.census.gov/instruct.html for a complete list of map features

off

Explicitly exclude certain map features

See http://tiger.census.gov/instruct.html for a complete list of map features

 

2.2.4. Mapping Census Data

But, wait, there's more! The TIGER Map Service also offers a means for generating simple maps of the Census Bureau's demographic data, in the form of thematic statistical maps. From the web interface, you can select a demographic variable, such as median income or population density, and a level of granularity to display that variable at, from statewide all the way down to a few city blocks. For example, Figure 2-5 shows the percentage of renter-occupied housing units in San Francisco at the Census block group level.

Figure 2-5. A thematic map of renter-occupied housing units in San Francisco

These maps were the precursor to the American FactFinder, which is a web site hosted by the Census Bureau at http://factfinder.census.gov/. The American FactFinder offers an unbelievable wealth of demographic information about the United States, as well as a whole suite of interactive maps based on the TIGER/Line data. We absolutely recommend devoting some spare time to exploring their site, especially if you have a particular interest in mapping demographics. However, we elected to devote an entire hack to the older TIGER Map Service because, for our purposes, the maps it produces are a lot easier to hack than those of its somewhat flashier successor.

2.2.5. The Pros and Cons of the TIGER Map Service

Before you get excited and start building mission-critical applications based on the TIGER Map Server, there are a few things to consider about these maps. First, they are made from map data dating back to 1997, so the maps may be somewhat outdated. Second, the TIGER Map Server is sometimes inexplicably slow or doesn't respond at all. Third, the service comes with no warranty at all. To quote from their instructions page:

The Census Bureau has continued to maintain the TIGER Mapping Service because it has proved useful to the general public. It was never intended to be a robust all-purpose mapping system to meet the needs of high-volume government, business or other organizations' applications... Any application that uses our mapping service does so at the user's risk. The Census Bureau plans continue to try to maintain the TIGER Mapping Service for at least the near future at its current level, but we accept no obligation to provide special support (or timely repair) of the system so that it can meet some other governmental, commercial or organizational mission.

On the other hand, as we've seen, these maps are pretty hackableand they're free!

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



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

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