# Preparing Data for TopoVista

This document outlines the steps involved in preparing data for viewing with TopoVista. Not all command options are described here; for further information see the individual program descriptions.

## File Formats

TopoVista reads elevation grids encoded in its own idiosyncratic TVG file format. These files are derived from Digital Elevation Models (DEM files) of 7.5 minute quadrangles prepared by the United States Geological Survey (USGS).

The USGS has used several file formats over the years. The native format is simplest, and its use is widespread. Currently, the USGS sells data in native format but gives away data encoded in the baroque SDTS format. The TopoVista package includes converters for both of these formats.

Independent of file format, USGS quadrangle data is available in two different resolutions (grid spacings). Data is available for the entire country at 30-meter resolution, and for many large and small areas at 10-meter resolution. TopoVista can use either, but they cannot be mixed.

The USGS also distributes another kind of STDS file containing quadrangle data in DLG (Digital Line Graph) format. These DLG files contain vector data that cannot be converted to the grids needed by TopoVista.

## Getting Quadrangles in SDTS Format

The USGS does not distribute SDTS files directly, but relies on distributors. Two good sources of free SDTS data files are MapMart and ATDI. MapMart has a nice graphical interface that provides up to ten quadrangles per batch in exchange for personal information. ATDI allows anonymous downloading of quadrangles specified by latitude and longitude.

Both of these sources have complete US coverage. The entire country is available in 30-meter resolution, and 10-meter files are distributed as they become available from the USGS.

## Getting Quadrangles in Native Format

Elevation grids can be purchased in native DEM format from the USGS.

DEM files converted from SDTS format are available for free downloading from WEBGis.com.

Some state agencies and university data centers distribute DEM files covering their particular regions.

## Converting SDTS data to DEM format

SDTS datasets require two conversion steps. First, the dataset is converted to a native format DEM file as outlined in this section. Then, the native DEM is converted to TopoVista TVG format as described in the following section.

An SDTS dataset is a gzipped (compressed) Unix tar file of several individual files. These files together comprise the elevation grid. The `SDTS2DEM` program reads these files and writes a native mode DEM file. SDTS2DEM is included in the TopoVista package; it is also distributed separately from its own web page at www.cs.arizona.edu/topovista/sdts2dem.

Conversion is most easily accomplished using the `tgztodgz` script, which handles the necessary unpacking and decompression. To use this script, make sure the TopoVista `bin` directory is in your search path, and enter `tgztodgz sdtsfile.tar.gz >demfile.gz` (substituting your own file names for sdtsfile.tar.gz and demfile.gz).

This script runs `SDTS2DEM` on the inputfile `sdtsfile.tar.gz` and writes a gzipped native mode DEM file to `demfile.gz`. The output file is now ready for conversion to TopoVista format, as described in the next section.

## Converting DEM data to TopoVista format

DEM files are converted to TVG format by the `tvconvert` script. This script reads one or more native DEM files named as command arguments and writes one or more `*.tvg` files to the current directory.

Multiple input files are combined before writing the output. Input files must come from the same UTM zone, must use the same datum (geographic coordinate system), and must have identical resolution. DEM files can be combined with TVG files on input to produce new TVG output files. DEM input files can be gzip-compressed (gzipped) or uncompressed.

TVG files do not correspond to USGS quadrangles in size or shape, so in general the number of output files differs from the number of input files. Output file names encode geographic coordinates and are chosen automatically.

To convert DEM files to TVG format, make sure the TopoVista `bin` directory is in your search path and enter `tvconvert quad1.dem quad2.dem quad3.dem.gz`, substituting your own list of input files. Output files are written in the current directory.

## Converting CTG files to color TopoVista data

USGS Composite Theme Grids (CTG files) can be used to color TopoVista terrain. To get CTG files, go to the US Geodata website and select `LULC` datasets. You will see several options for downloading files at two different resolutions. The 100K data files are smaller but 250K coverage is more complete. Navigate to the region you want and download the `grid_cell` file.

Now translate the CTG file into a PPM file using the program `ctg2ppm`. This program takes a CTG file and produces a PPM file that you can display using any image viewer. Comments in the PPM file specify the geographic coordinates covered by the image.

The PPM file is used in TopoVista by listing it on the command line after an elevation tile that overlaps it:

> `topo file.tvg file.ppm`.

The colors assigned by `ctg2ppm` to the various land use codes can be found in the file `ctg2ppm.c`.

INDEX