Tuesday, February 23, 2010

more VirtualPlanetBuilder fun

Let's add some other imagery to our Mt. Washington terrain. The digital orthophoto quadrangles published by the USGS are a decent source of free aerial photographs of the U.S. These images are rectified, which means that any effects from the tilt of the camera and relief of the terrain have been removed; just the thing for draping over a DEM. Unfortunately they are in black-and-white, but the resolution is 1 meter, which isn't bad. The image files are georeferenced, very convenient for building a mosaic with VirtualPlanetBuilder because we don't need to specify any additional projection or position parameters with each image. Generally one topographic map quad is divided into 4 DOQs. This makes for a marathon download session at the USGS website; maybe someone knows a better way?

It's straightforward to build a new database using an osgdem command similar to that used to build the map overlay database. One complication is that we now have 24 image files to deal with, instead of 5, and I don't feel like typing all the names on the command line. The downloaded files from the USGS have the form O4407145.NES.837049.tgz, and their only contents seems to be another tar file. Extracting that, we get the TIFF file and a header file. I arranged these all in directories; for example, the path to one TIFF file is O4407145.NES/O4407145.NES.837049.tif. We generate the command line with a little Unix magic:

ls O*.*/*.tif | sed -e's;.*;-t &;' \
| xargs osgdem --TERRAIN --geocentric -d elev-meters.tif \
-l 8 -o wash-photo.ive

We have a nice image when we look at the scene with osgviewer, although the gray imagery would benefit from colors and more contrast. But what would be very cool is display the topographic map tiles and the orthophotos on the same scene and transition between the two. VirtualPlanetBuilder lets you specify that images belong to different layers, and the OSG example program osgmultitexturecontrol supports transitioning between layers based on elevation above terrain. In order to build the new database, we need to specify a "--layer 1" argument before each orthophoto:

ls O*.*/*.tif | sed -e's;.*;--layer 1 -t &;' |\
xargs osgdem --TERRAIN --geocentric -d elev-meters.tif \
-t carter-dome-trim.tif -t crawford-trim.tif -t jackson-trim.tif\
-t stairs-trim.tif -t k44071c3/k44071c3-trim.tif \
-l 8 -o wash-layer.ive

Phew! Unfortunately, we don't see the map layer at all with the osgmultitexturecontrol program from the OSG distribution. A look at the code reveals the problem: the elevation at which the transition occurs is hard-wired at 1000 kilometers. That's fine for viewing a whole-earth database from space, but doesn't do us any good. I hacked in an elevation transition argument, and got some better results. We start with the map view:

and as we zoom in, we transition from this:

to this:

Pretty cool. It would be nice to spruce the photos up a bit, perhaps by using the approach of merging color from lower resolution LANDSAT imagery with these high resolution DOQs.

No comments: