DRGTools Version 0.30 - Beta Release, July 21, 1999

DRGTools are a set of programs for manipulating USGS Digital Raster Graphics (DRG) Topographic Maps. DRG maps are described in detail at the USGS DRG web page.

All DRG maps for New Mexico are available online. Go to this GPSy page for a good collection of links to other sources of maps around the United States.

The DRGTools programs have been tested on hundreds of maps during their development, but some bugs certainly remain. Please let me know if you find circumstances in which they do not work. Alternatively, if you use them and find that they work well, please let me know that also. My e-mail address is MikeW@rren.org.

The tools in this release are:

drgtool info: Prints the quadrangle name, scale and datum of a DRG file.
drgtool grid: Draws a UTM grid on a map.
drgtool join: Seamlessly joins adjacent maps together.
drgtool crop: Extracts a specified region from a DRG map.
drgtool copy: Copies a DRG file, optionally changing its compression type.
drgtool check: Performs consistency checks on the DRG GeoTIFF header.

New features in this release:

drgjoin writes .fgd files which support OziExplorer
New programs: drgcheck, drgcrop, drgcopy (replaces drgzip and drglzw)
All drgtool programs are now contained in the same executable (drgtool). This was done in order to minimize the size of the binary distribution, especially when statically linked with specially configured TIFF support libraries. Thus, "drginfo" has become "drgtool info". Symbolic links under linux and .bat files in DOS are supplied to reproduce the old behavior.

Windows 95/98/NT installation instructions

Shift-LeftMouse click on this link to download the drgtools.zip archive.

Use your favorite unzip proram to unzip it. I would suggest placing the files in c:\drgtools and then editing your autoexec.bat to place drgtools in your execution path, i.e. "SET PATH=%PATH%;C:\DRGTOOLS" These programs are intended to be run from an MSDOS window.

Linux installation instructions

Grab this binary distribution and do the usual things to it. This is a statically linked version which should run on any linux distribution.

Other systems

Grab the source code below and compile It is unlikely that I will be able to get these programs to work on a Mac, since I don't have access to one with the compilers and other necessary software libraries.

Source code

The source code is available at this link

Old releases

The initial 0.22 binary-only release can be found at this page.

Copyright and Disclaimer

/* DRGTools -- Tools for manipulating USGS DRG files
 * Copyright (C) 1999 Michael S. Warren 
 *
 * These programs are free software; you can redistribute them and/or modify
 * them under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * These programs are distributed in the hope that they will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

Documentation on individual programs

info

Usage: drgtool info [options] file1 ...

Function: info prints information from a DRG GeoTIFF header

Options:
 -y Include map publication year (requires .fgd file)
 -l More detailed (long) output
 -f Create .fgd file for map
 -t Create .tfw file for map
 -o output_dir	Specify directory to put .fgd or .tfw files into
C:\msw\data>drgtool info o35105f8.tif
o35105f8.tif  1:24000 NAD27 "Santa Fe"

C:\msw\data>drgtool info -l o35105f8.tif
File name: o35105f8.tif
Description: USGS GeoTIFF DRG 1:24000 Quad of Santa Fe. Product:603100
Software: USGS CD Archiver program tif2usgsdrg v.1.0
Date and Time: 1997:07:03 13:45:07
Origin (UTM): 408.665 3957.256 kilometers
Latitude: 35.625 degrees
Longitude: -105.875 degrees
Height: 0.125 degrees
Width: 0.125 degrees
Datum: NAD27
Zone: 13 N
Pixelscale: 2.438400 meters
Image Width: 5328
Image Length: 6740
Compression: packbits
Resolution: 72 dpi
You can get a whole directory of map info by using the * filename wildcard

C:\msw\data>drgtool info E:\DATA\*.TIF
will print the information for every map on the CD-ROM in drive E.

grid

Usage: drgtool grid [options] infile [outfile]

Function: grid draws a UTM grid on a map

Options:
 -c {lzw, zip, packbits, none} Compression type
	default is to use same as input file
 -q Be quiet
 -r Replace input file with output
"drgtool grid infile.tif outfile.tif" puts a UTM grid on infile.tif, and writes it to outfile.tif. The grid is 1km for 1:24k maps, and 10km for 1:100k or 1:250k scale maps.

join

Usage: drgtool join [options] infile1 infile2 outfile

Function: join seamlessly joins two DRG maps

Options:
 -c {lzw, zip, packbits, none} Compression type
		default is to use same as input file
 -f Create .fgd file for joined map
 -n "Map Name"	Set map name to that specified
 -q Be quiet
 -r Replace existing file with output
"drgtool join infile1.tif infile2.tif outfile.tif" joins the two maps specified, and writes them to a third file. The maps must be adjacent and the same scale, but can be either left/right or top/bottom neighbors and either 24k, 100k or 250k scale maps. You can join pairs of maps, and then join the resulting files together, and produce mosaics of 4 or more maps that way. The format of the output file is identical to the input files, so you can use the same viewing software you normally use to view the joined maps. If you want to view the resulting joined map in Fugawi or OziExplorer, it needs a corresponding "outfile.fgd" file, which you can tell the program to generate by giving it the "-f" flag.

Example execution:

C:\msw\data>drgjoin -f e:\data\o35105f7.tif e:\data\o35105f8.tif temp4.tif
e:\data\o35105f7.tif  1:24000 NAD27 "McClure Reservoir"
e:\data\o35105f8.tif  1:24000 NAD27 "Santa Fe"
Joining East and West.
Done.

crop

Usage: drgtool crop [options] infile outfile

Function: crop extracts a specified region from a DRG map

Options:
 -x x_center[.UTM] Specify east-west center of map
 -y y_center[.UTM] Specify north-south center of map
 -w width[.UTM]  Specify width of extracted map.
 -h height[.UTM] Specify height of extracted map
Note:
  center/width/height parameters are specified in pixels, unless the value
  contains a decimal point, in which case it is interpreted as UTM (km)
 -2 {n,s,e,w} Extract specified half of map
 -4 {ne,nw,se,sw} Extract specified quarter of map
 -c {lzw, zip, packbits, none} Compression type
	default is to use same as input file
 -n "Map Name"	Set map name to that specified
 -q Be quiet
 -r Replace existing file with output

copy

Usage: drgtool copy [options] infile [outfile]

Function: copy copies a DRG file, optionally changing its
  compression type or other features

Options:
 -c {lzw,zip,packbits,none}	Set compression type
  default is to use same as input file
 -b {lsb2msb,msb2lsb}	Set byte ordering
 -n "Map Name"	Set map name to that specified
 -q Be quiet
 -r Replace input file with output
Copy converts the compression type of a DRG file. Files are packbits compressed as distributed from USGS. lzw and zip compression of DRG maps usually results in files which are about 1/2 the size of packbits compressed files. Not all image readers support lzw or zip compressed TIFF files, however. lzw compression is patented by Unisys, so zip compression is the standard which should be preferred for widespread DRG map distribution when minimum file size is an important factor.

Note that this type of compression does almost as well as gzip or pkzip compression of a whole map file, but has the benefit of allowing an image reader to randomly access a given scanline without having to uncompress the whole file.

Example execution:

C:\msw\data>drgtool copy -c lzw e:\data\o35105g7.tif temp.tif
e:\data\o35105g7.tif  1:24000 NAD27 "Aspen Basin"
Done.

check

Usage: drgtool check [options] file1 ...

Function: check sanity checks information from a DRG GeoTIFF header

Options:
 -q	Quiet, only print information if there is an error
 -w	Check that all the image data is readable as well
 -e tol	Sets error tolerance to "tol" meters. Will not
	report errors for distances smaller than that.

Other notes

California maps supplied by the Teale data center are not supported by
this software.

Problem: Clicking on the drgtool program pops open a window which
disappears immediately.

Solution: You need to explicitly open a DOS window before starting
a program if you are using Windows 95/98/NT.

Problem: Trying to produce a zip/deflate compressed file produces the
message "Deflate compression support is not configured."

Solution: Your TIFF library was not compiled with ZIP support.  The
standard libtiff is almost never distributed with ZIP="yes" in the
config.site file, so you will need to recompile it yourself if
you want to build drgtools which support zip from the source code.
Michael S. Warren, MikeW@rren.org