USGS logo

Digital Mapping Techniques '98 -- Workshop Proceedings
U.S. Geological Survey Open-File Report 98-487

Recipes for Digital Cartography: Cooking with DEMs

By Ralph Haugerud1 and Harvey M. Greenberg2

1U.S. Geological Survey
Box 351310
Seattle, WA 98195
Telephone: (206) 553-5542
Fax: (206) 553-8350
e-mail: rhaugerud@usgs.gov

2Dept. of Geological Sciences
University of Washington
Box 351310
Seattle, WA 98195
e-mail: hgreen@u.washington.edu

INTRODUCTION

For almost all purposes, shaded relief is more effective and efficient than contours for visualizing topography. The cartographic costs -- mostly, restriction of the color and pattern palette available for portraying thematic map information -- of a shaded-relief base are greatly outweighed by its benefits. Topography and geology are natural cartographic complements; most geologic maps are more informative when produced on a shaded-relief base. Such maps are best produced from digital elevation models (DEMs) and digital thematic map data, using the tools of digital cartography.

Like good cooking, good digital cartography is guided by taste, a knowledge of basic principles and materials, and master recipes that emphasize technique. Here we report principles and recipes that we hope others will find useful for working with DEMs. We assume our readers have some familiarity with Arc/Info and AML (Arc Macro Language). This note is not a primer to the GRID module of Arc/Info. Skill with GRID or a similar tool is necessary for working effectively with DEMs. You can acquire such skill by reading the documentation and experimenting; we are learning GRID this way.

We apologize for how hopelessly ARC-centric we are. We are so ignorant of other GISs that we don't even know to what extent the procedures given here can be adapted to them! (We hope they can be.) We don't mean to recommend Arc/Info as the only software suitable for digital cartography. We use it because it has been available and we have learned how to use it. We are currently working with Arc/Info version 7.1.2, under Solaris 2.5.1 and 2.6, on Sun Ultra hardware. Disk space on our systems is measured in the 10s of gigabytes. We share an HP650C plotter and currently use versions 1.0 and 2.0 of ArcPress. We have not installed any plotters in Arc/Info; we create plot files in ARC and queue these files to the plotter from the UNIX command line.

Bon appetit!

PRINCIPLES

Know Your DEMs

The quality of DEMs distributed by the USGS varies widely. The nominal quality descriptors (Level 1, Level 2, Level 3) do not adequately depict their usability. In general:

Before using any DEM, you should merge it with any adjoining DEMs you will also use, plot a shaded-relief image (recipe 6), and examine it closely. Look especially at large areas of low relief, at DEM boundaries, at shorelines, and at double-line rivers. Boundary mismatches may reflect mismatches in the source contours or may be artifacts of the DEM generation process. Then make histograms of Z values in each DEM (recipe 5) to appreciate some of the systematic errors that may be present.

USGS standards for DEMs (http://mapping.usgs.gov/www/ti/DEM/standards_dem.html; U.S. Geological Survey, 1990) contain no specifications for the quality of slope values calculated from DEMs. Slopes are commonly the most important aspect of DEMs for visualization; those who use DEMs for visualization must make their own assessment of the suitability of each DEM for such use.

Avoid Projecting DEMs

To project a DEM is to degrade it. A map should be made in the way that best honors its constituent data. Geology is generally in vector form, and thus easily projectable. Other raster data are generally less voluminous than topography. Thus, project other data into the DEM projection. For large-scale maps of areas within the United States, this means that you are working in UTM coordinates, datum NAD27. The significant exception to this rule is intermediate- or small-scale maps made with high-resolution DEMs, where the DEM is resampled to a significantly larger cell size.

Know Your Output Device

Graphics are device-dependent. As output devices and page-description languages improve this becomes less so, but for now it pays to learn how your output device responds to your instructions, and to customize your plotting procedures for your device.

Our experience is with large-format inkjet plotters. Among the rules we have learned (some the hard way) are:

The number of dots in an ordered dither cell puts a limit on the number of colors the plotter can produce. A random dither only partially avoids this problem. We look forward to acquiring a higher resolution plotter largely for its greater color depth.

Lines are 1, or 2, or n dots wide. Linesizes of 0.003" and 0.005" may be effectively the same width (1 dot) on your 300 dpi rasterizer/plotter. Experiment to find out (try recipe 1), and adjust your plot procedures accordingly.

Empirical Cartography

One of the great delights of GIS is that it makes cartography easy, in the sense that given operations can be repeated with little effort. With this ease of repetition comes the ability to make and remake a map, changing line weights, colors, text fonts, and so on until the map looks right. Plan on making your maps more than once.

Work from Scripts!

The ease of remaking a map is only maximized when you aren't typing long sequences of commands. Always work from scripts! Version-to-version improvements in a map are then accomplished by editing the scripts. Often building a map is a sequence of operations: assembling primary data coverages (by copying or clipping) and massaging intermediate coverages, drawing a graphic to the screen for an initial check on plot quality, and making a paper plot. We typically use three scripts (macros) for this sequence: makemap, drawmap, and plotmap. Makemap assembles and massages the primary data and has no graphics commands. Drawmap comprises graphics commands but does not specify the output device, and thus can be used to draw the map to the screen or to a plot file. Plotmap specifies the output device to be a plotfile and calls drawmap, rasterizes the resulting plotfile, and sends it to the plotter.

Understanding a map to be the product of primary data and a set of scripts (1) allows the map to be easily revised when the primary data are improved, and (2) eases storage space requirements. We try to discard intermediate coverages (unless they contain significant additional manual editing) and plot files, and only retain scripts. Working with scripts has the additional advantage of (3) preserving the cartographic tricks you have learned in written form, where they can easily be recycled by cutting and pasting.

Learn Some Programming Skills

Elementary programming skills will speed your cartography. Learn to use variables wherever possible. Isolate repeated sets of actions as routines or free-standing macros that are called by other parts of your script(s); this will make it much easier to recycle your scripts into the next map. A course in Pascal or another strongly structured programming language may be appropriate, simply to learn these habits of thought.

Have Enough Disk Space

DEMs gobble disk space. Depending on its size, a single map can require up to 0.5 GB of input DEM. You may multiply this by a factor of 5 in the course of constructing the map. Access to 2-3 gigabytes of free disk space is not unreasonable.

Learn the HSV Color Model

For mapping entities that are continuously variable (such as elevation and slope), a simple enumerated shade set may not be adequate to describe the colors on your maps. Color is then more usefully described using an effectively continuous color model (RGB, CMY, or HSV). HSV (Hue, Saturation, Value) is a natural way to describe the colors of topographic surfaces, for the V component can be assigned on the basis of brightness as calculated with the HILLSHADE command in GRID. Recipe 3 makes a hue-saturation color chart.

We know of two caveats to the HSV color model. First, machine (monitor, plotter) saturation is not proportional to human-eye saturation. At a given nominal saturation value, red, green, and blue appear more saturated to the eye than do yellow, cyan, and magenta. For the highest quality work, you may choose to calculate saturation as a (partial) function of hue. Second, ARC may unpredictably (but repeatably) produce undesirable effects when a Value grid contains values of 100. To avoid this, we routinely limit the maximum value to 99, which produces pale-gray collars around our maps. The gray can be masked with a white polygon when it is objectionable.

Think about Symbolization Space

When designing maps, it can be useful to imagine a multi-dimensional space defined by the available range of color (hue, saturation, value), and to reserve certain parts of this space to certain parts of the meaning of the map. A color shaded-relief base map that uses all the available color space will not work well as a backdrop to vector data. The necessary overlap of hue, brightness, and (or) saturation between the backdrop and the overlaid vector data will make the map too busy. A simple solution is to make room (in symbolization space) for overlaid vector data by narrowing the range of saturation and value, perhaps to NewSaturation = OldSaturation/2 and NewValue = 100 - OldValue/2. Then overlay the raster base with vector data plotted in fully saturated colors.

The concept of reserving certain parts of symbolization space for certain categories of meaning can also be applied to text, markers, patterns, and line-types.

RECIPES

Macros are not reproduced here because of space limitations. They are available online at http://duff.geology.washington.edu/gis/recipes/ or may be obtained with an e-mail request to either author.

We hope these macros will be used, revised, and shared. If you significantly revise one of our macros, please note this in the macro header before you pass it on:

     /* revised by <YOUR NAME> <YOUR EMAIL ADDRESS> <DATE>

To make the structure of the macros more evident, and to shorten them, almost all error-checking is omitted. Similarly, all macros are designed to be run in the workspace that contains all other elements (input coverages, grids, lookup tables, other macros, and output) of the procedure. Both are questionable practices. Many of the macros will require minor editing before they can be used succesfully; unless a macro is to be called by other macros, we prefer hard-coding input parameters into the macro header to retyping them each time the macro is run.

All macro names are suffixed with .AML; these suffixes are generally omitted here. We work on UNIX systems that are tolerant of long file names. Those less lucky may need to rename some macros and some variables that specify file names within the macros.

1. Test linewidths on your rasterizer/plotter

Ingredients: Macros DRAWTEST, PLOTTEST

DRAWTEST creates a plot with single-stroke text (lines of varying orientations) of many linesizes. Look at the macro to see the use of a simple loop control (&do n = ...&end).

In Arc, type &RUN PLOTTEST. This will start ArcPlot, set DISPLAY 1040, call DRAWTEST, and create a graphic metafile called linetest.gra. Rasterize the plotfile using ArcPress, RTL, or other tool as appropriate, and plot it. Or convert the metafile to Postscript (see recipe 3) and use the plotter's Postscript interpreter to rasterize.

Look at the resulting plot with a hand lens. At what nominal line-sizes does your rasterizer/plotter combination change from one-pixel lines to two-pixel lines? Two-pixel lines to three-pixel lines?

2. A symbolset

Ingredients: IGL font fnt035, shadeset rockpat7.shd, macro MAKEINKJETPAT.

Plotter.shd and many of the simple markersets provided with ARC don't work well with an inkjet plotter. Yet geologists need pattern overprints to distinguish units. MAKEINKJETPAT produces the shadeset INKJETPAT.SHD which comprises a set of patterns suitable for overlays on geologic maps. Relevant features are:

Problems with this shadeset include:

Similar procedures work for building a markerset or a lineset. Producing a new font with templates for other patterns is not that difficult; read the on-line documentation.

3. A hue-saturation color chart

Ingredients: Macros MAKEHSV, DRAWHSV, and PLOTHSV.

A hue-saturation color chart is essential for designing colored thematic maps (e.g., geologic maps) with shaded-relief bases. Plotting it can give you a sense of the color depth of your rasterizer/plotter combination. You can also use it to get a sense of the effects of different rasterizers. To make the components of an HSV color chart, type &RUN MAKEHSV at the ARC prompt. Macro DRAWHSV runs from ARCPLOT and draws the HSV chart. To plot the color chart, edit macro PLOTHSV to suit your rasterizer and printing system and type &RUN PLOTHSV at the ARC prompt.

To evaluate the effects of different rasterizers,

  1. plot an RTL file generated with ARC's RTL command
      Arc: RTL hsv.gra hsv1.rtl # # # # 0
  2. plot an RTL file generated with ArcPress
    Arc: &sys ARCPRESS hsv.gra -ohsv2.rtl -dHP650C_CMYK -v

    (note that the -d parameter is for an HP650C with ArcPress 1.0. It will be different for a different plotter and in ArcPress 2.0)

  3. use the internal Postscript rasterizer in your plotter, if it has one, by creating a Postscript file and plotting it.
    Arc: &sys echo 'compress 0' > compress0

    (This creates a one-line file Postscript parameter file that says "compress 0." If you don't use the compress 0 option, ARC defaults to a compressed Postscript that chokes most Postscript interpreters if the plot file contains a large bitmap.)
    Arc: POSTSCRIPT hsv.gra hsv.ps # compress0

The hue-saturation chart produced by these macros has value set to 98. This has proven suitable for designing geologic maps on shaded-relief bases where the shading is lightened and restricted as in recipe 9. You may want to try other values. The change is easy to make (line 33 in macro MAKEHSV).

4. Make your own DEM from DLG hypsography

Ingredients: DLGs downloaded from ftp://edcftp.cr.usgs.gov, macros IMPORTDLGS, ADDZ, and the ARC TOPOGRID command.

The DLGs (Digital Line Graphs), on-line at the Eros Data Center (ftp://edcftp.cr.usgs.gov/pub/data/DLG; see also http://edcwww.cr.usgs.gov/), are a great resource. Most of the elements, except annotation, for standard 1:100,000-scale 30'x60' maps for all of the conterminous United States are available through the Internet at no cost.

Good (contour-derived) 30-meter DEMs are not yet available for much of the United States. In their absence, DEMs that may be adequate for use as backdrops to other data can be produced from the 1:100,000-scale hypsography DLGs, which are available for most of the country.

To make such a DEM,

Note that ADDZ is NOT warranted to work in all situations. We know it fails with some intermediate contours. You should be able to improve the macro. In some cases contours may be misattributed in the DLGs. Check your results, either by making a TOPOGRID DEM and inspecting it (easy, but may take lots of processing time), or by the following scheme, for which we thank Alan Rea (USGS, Oklahoma City):

* Grid: CONTOURGRID = linegrid (CONTOURCOVER, Z, #, #, 30)
* Grid: ZGRID = eucallocation (CONTOURGRID)
* Grid: DIFFGRID = slope(ZGRID, PERCENTRISE)
* Grid: DESCRIBE DIFFGRID 

If DIFFGRID has any values greater than contour interval / gridsize, you have a mislabelled contour (or a coarse cell size included two contours in one grid cell.) To identify mislabelled contours, first create the file dgpaint.aml that reads

shadeset rainbow 
gridshade diffgrid # linear

Then, in ARCEDIT,

Arcedit: editcover <contourcoverage>
Arcedit: drawenvironment arc
Arcedit: editfeature arc
Arcedit: ap dgpaint.aml
Arcedit: draw

TOPOGRID fits splines to the input data, and thus is prone to overshoots and undershoots at the tops and bottoms, respectively, of slopes. To examine your TOPOGRID-derived DEM for the resulting billowy topography, make and plot a shaded-relief image with MAKESR, DRAWSR, and PLOTSR (recipe 6, below). Add the following lines to DRAWSR before the penultimate line:

lineset plotter.lin
linesymbol 1
linecolor yellow
arcs <contourcoverage>

5. Histograms of DEM Z values

Ingredients: One DEM, macros DEMHIST1, DEMHIST2.

Usage: Grid: &RUN DEMHIST1 <DEM-name>; &RUN DEMHIST2 <DEM-name> <contour interval> <contour units (in DEM Z units)>

A large random sample of elevations from real topography will produce a fairly smooth histogram, excepting big spikes that correspond to lakes and the sea. An ideal DEM should also show an even distribution of Z values, but most DEMs derived from contours show biassing towards contour values.

These macros make histograms of Z values that demonstrate such biassing. DEMHIST1 makes a histogram of values over a range of +/- 100 units from the approximate mean elevation of the input quadrangle. If you know, or can guess, the contour interval of the map from which a DEM was made, use DEMHIST2 which makes a histogram of DZ values, where DZ is the difference from the (vertically) closest contour value.

DEMHIST1 creates an output grid that is not deleted; to run it a second time you must KILL grid <DEM-name>h1. Similarly, DEMHIST2 creates grid <DEM-name>h2.

DEMHIST1 and DEMHIST2 do not specify an output device. Run them from GRID with DISPLAY 9999 3 for the best on-screen graphic. Or specify DISPLAY 1040 and an appropriate pagesize before running each macro.

6. A simple shaded-relief map

Ingredients: One DEM, macros MAKESR, DRAWSR, PLOTSR

Usage: from ARC, &RUN DRAWSR <DEM-name>; &RUN PLOTSR <DEM-name>

MAKESR makes a shaded-relief map that will emphasize the stripey character of profiled DEMs. It maximizes the contrast of the DEM to show fairly subtle changes of slope at all slope angles. The resulting dark, contrasty image is not suitable for a base map; see recipe 7 for that. For a paper version of the shaded-relief map, edit PLOTSR for the mapscale and &RUN it. After you have finished, KILL the intermediate grid <DEM-name>shd.

7. Some shaded-relief variants

Most shaded-relief images are not directly suitable for use as base maps. We routinely lighten and modify the contrast on our images by

Grid: &DESCRIBE %shdgrid%
Grid: xxg1 = INT(((%shdgrid% - %GRD$MEAN%) * %NewStDv% ) / %GRD$STDV% + %NewMean%)

&DESCRIBE %shdgrid% sets the predefined variables GRD$MEAN and GRD$STDV to the mean and standard deviation, respectively, of %shdgrid%. The second statement creates a new grid with the mean brightness shifted to NewMean and scales the standard deviation to NewStDv. To make a Value grid (black = 0, white = 100) for a geology-on-shaded-relief map (below), we typically set NewStDv = 15 and NewMean = 95. One then usually needs to truncate the resulting grid to eliminate too-dark and illegal values:

Grid: NewGrid = CON(xxg1 < %min%, %min%, xxg1 > %max%, %max%, xxg1)

For value grids used with the HSV color model to make geologic maps, we typically set Min = 70 and Max = 99. (If you will plot a gray-scale image with the GRIDPAINT command, NewMean, Min, and Max may be in the range 0-255.) Other uses will dictate other values of Min and Max.

Macro DEMSR uses a DEM, coverages of standing-water and glacier outlines, and the the HSV color model to create a color shaded-relief image. It HILLSHADEs the DEM, calculates a value grid from the the result, calculates hue as a function of elevation, and sets saturation to a constant. It then converts the standing water and glacier coverages to grids, calculates hue and saturation grids for water and glacier, and then MERGEs these with the z-derived hue and saturation grids. For more control over the colors created by DEMSR, substitute table-driven SLICEs to calculate hue and saturation from the input DEM.

We have found another variant of color shaded relief useful for comprehending the geomorphology of low-relief areas. Macro EDGES calculates value from slope, with steeper slopes (up to some threshhold) corresponding to higher values (darker areas on the resulting image). EDGES calculates hue as a stepwise function of elevation. The resulting image emphasizes subtle changes in slope in low-slope areas and allows immediate identification of similar (and different) elevations.

8. Geology on shaded relief

Ingredients: Polygon coverage of geology, DEM, look-up table describing colors of geologic units in terms of hue and saturation (start by running macro GEOUNITS), and macro SRGEOL.

The HSV color model is key: shaded-relief provides the V component, and geology (or other map theme) provides the H and S.

To use macro SRGEOL, you first create a lookup table that describes hue and saturation values for each polygon-type in the geology polygon coverage. So,

The important features are the numeric values for hue and saturation. The other items -- tag, pattern, and unit-name -- could be omitted. We include them because (a) tag gives the freedom to change map-unit labels without having to alter the underlying coverage, (b) pattern easily specifies overprint patterns, and (c) unit-name makes the resulting file and look-up table easier to read and edit. Rename <GeoCoverName>.UNITS to all lower-case characters.

Note that SRGEOL is designed to be run until it fails, the cause of failure corrected and identified, and the macro re-run. The most likely causes of failure are an improperly named or formatted *.UNITS file and incorrect definition of the info file SYM.<map> in routine SymInfo. As you evolve a coloring scheme for a map by making a map, looking at it, and identifying new hue, saturation, and pattern values for the geologic units, you can edit the UNITS text-table, KILL grids <mapname>hg and <mapname>sg, and rerun SRGEOL.

9. Geology on shaded relief under a DRG

Ingredients: HSV grids for a geologic (or other thematic) map, as created with recipe 8; a coextensive DRG; and macro DRGTHEME.

USGS Digital raster graphics (DRGs) are rectified, color-classified intermediate-resolution (circa 300 dpi) scans of standard topographic maps. Our limited experience with them suggests that the classification of pixel colors is too inconsistent for most analytic uses (e.g. separating contours from other features and vectorizing them). However, when plotted at the scale of the source-map, many DRGs make quite acceptable images. Macro DRGTHEME

For the best results, prepare the HSV thematic-map grids at a resolution appropriate to the scale of the final map. 1:24,000-scale maps which use shaded-relief as a component of the thematic map require circa 10-meter DEMs as input.

The resulting maps can have a complexity that strains the resolution and color depth of our 300 dpi HP650C plotter. They are significantly better when rendered on an HP2500C plotter.

10. Synthetic stereopairs

Ingredients: DEM, HSV grids from recipe 7, 8, or 9, and macro STEREO.

With a picture-map and DEM, it is straightforward to drape the picture-map on the DEM to create a perspective image using the SURFACE commands in ArcPlot. With the appropriate pair of viewpoints of the same map-area, one can create a pair of images that have the same geometry as stereoscopic aerial photographs. The resulting images can be viewed with a stereoscope and are an excellent way to teach map reading and communicate map relations.

Macro STEREO automates this process. To run it:

If you have developed a macro to plot other elements of a map (contacts, faults, symbols), it is a simple matter to paste it into routine AnImage of macro STEREO. Be sure to precede each plotting command (e.g. ARCS, MARKERS) with SURFACEDRAPE.

Note that ARC plots perspective views rather slowly. Each pixel, including hidden ones, of a view appears to be preserved in the resulting graphics metafile. Subsequent rasterizing is slow and if you must create intermediate Postscript files they are unduly large.

For stereopairs you may wish to have your value grids contain more information than is desirable for a geologic map. This requires that they have a greater range of contrast and be darker overall, e.g. with mean value circa 80, standard deviation circa 30, and minimum value circa 50. See recipe 7.

11. Mapping on a DEM

Many geologic features are commonly mapped from landforms. Faults follow gullies. Quaternary alluvium ends where the valley floor butts up against steep ground. Older alluvium underlies terraces, and so on. When putting geologic maps on a shaded-relief base one quickly notices mismatches between contacts of Quaternary units and the representations of landforms (valley-bottom margins, terrace margins, and so on) with which they should coincide. An obvious step is to map these geologic features directly on an image derived from a DEM.

To do so,

ACKNOWLEDGMENTS

Haugerud thanks the Geophysics Program at the University of Washington for friendly and competent system administration, and the USGS National Earthquake Hazard Reduction Program for subsidizing plotting costs. A review by David Soller improved the clarity of our presentation.

REFERENCE

U.S. Geological Survey, 1990, Digital Elevation Models: U.S. Geological Survey, Data Users Guide 5, 51 p.

Home | Contents | Next

U.S.Department of the Interior, U.S. Geological Survey
<https://pubs.usgs.gov/openfile/of98-487/haug2.html>
Maintained by Dave Soller
Last updated 10.07.98