When you need to explore a new area but don't have a quick way to get a "bird's-eye" view of the land, a GIS browser can come in handy.
Sometimes you find yourself interested in an area, perhaps for recreation, relocation, or just out of an overwhelming sense of curiosity. There are many sources of free GIS data and imagery available on the Internetmaybe you've gotten a hold of a piece of geospatial data and just want to see what it contains. In this hack, we are going to explore a new area by downloading an aerial photograph and the corresponding topographic map. We will use Quantum GIS, or QGIS to its friends, to display the data. QGIS runs under Linux and various flavors of Unix.
First you need to download and install QGIS. QGIS source code, RPMs, and installation instructions are available from http://qgis.org/. Debian Linux users will find the apt repository at http://bullhorn.org/debian/ useful.
6.2.1. Selecting Our Area of Interest
The first task is to find the spot we are interested in and download some data. Suppose we want to make a trip to the Grand Canyon and are interested in taking a look at some of its features prior to traveling. For the purposes of this hack, we will choose an area around Burro Canyon. The next task is to find the image(s) and topographic map from a free source. Since we don't know exactly where Burro Canyon is (we've only heard about it in line at the espresso stand), we will use the USGS Geographic Names Information System search tool.
6.2.2. Finding Our Spot
The GNIS tool can be found at http://geonames.usgs.gov/gnishome.html. GNIS contains information on about two million geographic features in the U.S. The other good thing about GNIS is that it is integrated with Terraserver [Hack #4]. Once we find the right Burro Canyon, we can jump right to the data we want. The GNIS search page allows searching by feature name, state, county, elevation, feature type, and some other parameters. Figure 6-1 shows the GNIS search page with our Burro Canyon search parameters already entered.
Figure 6-1. Searching the GNIS
After running the query, we are presented with a list of eight candidates that match our search criteria. A little clicking around reveals that the Burro Canyon in the Havasupai Point 7.5-minute quadrangle is the one we want. By clicking on the hyperlink shown in Figure 6-2, we can get to the page that has links to both the USGS Digital Orthophoto Quadrangle (DOQ) aerial photograph and the Digital Raster Graphic (DRG), which is the digitized USGS topographic map. Microsoft's Terraserver [Hack #4] hosts both of these items.
Figure 6-2. Search results from the GNIS
6.2.3. Getting the Data
Using the DRG and DOQ links on the GNIS search result page, we can navigate Terraserver and download the images.
To fetch the DRG:
Now we have the georeferenced DRG saved as a JPEG image.
Next we will get the DOQ for the same area. Click on the "Back to Terraserver" link below the DRG image to go back to the map display. To download the DOQ:
6.2.4. Displaying the Data
Now we can look at the data layers we have downloaded. The advantage to using a GIS is that we can view the layers along with other data we might have. QGIS allows you to overlay multiple layers, including data imported from a GPS using the QGIS GPS-importer plug-in.
To display the Burro Canyon data, start QGIS and follow these steps:
QGIS should now look similar to Figure 6-3. Your view may look different if the DRG was loaded on top of the DOQ.
Figure 6-3. QGIS, with the Burro Canyon DOQ and DRG loaded
It's not very useful to have one image covered up by the other, so QGIS allows you to set transparency on an image. With the topographic map and aerial photograph, we can get an interesting, almost 3-D appearance by setting the top layer to about 55 percent transparency. To set transparency for the DOQ (our top layer), double-click on the burro_canyon_doq name in the legend. This will bring up the "Raster Layer Properties" dialog shown in Figure 6-4.
Figure 6-4. QGIS's Raster Layer Properties dialog
Click on the Symbology tab, move the transparency slider to the desired level, and click the Apply button. There are a number of other settings that can be adjusted. You can modify the colors, invert the color map, and change the pseudocolor. On the General tab, you can set the display name for the layer. Right now the display name is set to the filename. You can change it to something more aesthetically pleasing if you like.
After adjusting the transparency and any other setting you would like to change, click OK. Now we get a pseudo-3-D effect with the aerial photo and the topographic layer working together, as shown in Figure 6-5. Notice that we have changed the display name for the two layers. We also zoomed in a bit to better display the Burro Canyon area.
Figure 6-5. QGIS, showing Burro Canyon, with the DOQ layer at 56% transparency
6.2.5. Adding Vector Data
The pseudo 3-D image is nice to look at, but we could add more data to the map that would give us even more information. Some examples might be GPS tracks or waypoints, cultural features, or other boundaries. There are numerous sources of free data on the Internet. Since the Grand Canyon is a National Park, data is available from the National Park Service clearinghouse at http://nps.gov/gis/data_info/clearinghouse.html. Using the clearinghouse web site, you can download data by selecting a state and viewing what's available. Following the links to Grand Canyon National Park, we can download additional data for our area of interest. To give this a try, download the hydrology data from http://www.nps.gov/gis/park_gisdata/arizona/grca.htm, unzip it, and add the hydro_main (rivers/streams) layer to the map.
184.108.40.206 Projection problems
The first thing you will notice is that, as Figure 6-6 illustrates, the newly added hydro layer does not line up properly with the topographic or DOQ layer. The hydro layer is offset to the southeast of the topographic layer, which is a sure sign that something is amiss with the cartographic projections used in our two data sets.
Figure 6-6. Datum problem
In this case, we have a classic example of datum mismatch. The Terraserver images are based on the North American Datum of 1983 (NAD83). If we look at the metadataa really useful thing to do when using GIS datafor the hydro layer, we see that the spatial reference section indicates that it uses the North American Datum of 1927 (NAD27). The difference between these two geodetic datums, or coordinate origins, can be off by as much as a kilometer, depending on the latitude and longitude.
220.127.116.11 Dealing with it
We could do a datum transformation using the NadCon standard (http://www.ngs.noaa.gov/TOOLS/Nadcon/Nadcon.html), provided that we had appropriate tools at our disposal. Alternatively, we could try using the ogr2ogr tool to transform the hydro layer into the NAD83 datum, as described in detail in [Hack #68] . Or, we can just do a quick hack to line up the data, realizing that:
18.104.22.168 Making it line up
Remember the world files we downloaded for each of the images? We can modify them to get a better alignment between our images and the hydro layer. A world file consists of map units per pixel, rotation information, and, most importantly for our purposes, the coordinates of the upper left corner of the image. By modifying the x- and y-coordinates of the upper left corner, we can "move" the image. The world file for the topographic layer contains:
16.000000 0.000000 0.000000 -16.000000 371200.000000 4016000.00000
These last two lines represent the upper left corner of our image, in meters from the projection origin.
First we must determine the offset. Zoom into an area with an identifying feature, such as a stream intersection or sharp bend. QGIS displays the (x, y) coordinate of the cursor in the status bar. This information can be used to get the coordinates of our stream intersection on the hydro layer and on the topographic layer. By calculating the difference, we can adjust the world file to line up the image with the hydro layer.
The x and y offsets are approximately 112 meters and 197 meters, respectively. Edit the world file stored in burro_canyon_topo.jgw and change the (x, y) coordinates in the last two lines of the file accordingly:
16.000000 0.000000 0.000000 -16.000000 371312.000000 4015803.000000
We can now remove the topo layer from QGIS and add it back in to see the changes. Figure 6-7 shows the same view with the adjusted topo layer. Note that the hydro layer now lines up much better. Remember this is a hacknot the recommended way to transform rasters to match other data. But for display/cartographic purposes, it is one quick-and-dirty way to line up the data.
Figure 6-7. After manually adjusting the world file
6.2.6. In Conclusion
With a large amount of free data available on the Internet, we can fairly quickly display an area of interest. QGIS, in conjunction with the other web sites and tools available, makes it easy to visualize the data. Sometimes the data are in differing projections and/or datums, but with a little clever manipulation, you can always torture it into submission.
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