Chapter 12: Surface  


Surface is a 2-1/2 dimensional visualization program for viewing regularly gridded data as a color contoured, gradient, or shaded relief surface. It is included in the UNCERT software as a tool to view the values in a two-dimensional array as three dimensional surface. This is referred to as a 2-1/2 dimensional surface because for each X-Y grid location, there is only one Z value. In a true 3D model (see block, Chapter 13) each X-Y location may have multiple Z values. This package is used to view gridded surface data generated from grid (Chapter 10), or for examining layers or cross-sections from sisim (Chapter 14), MODFLOW (McDonald and Harbaugh, 1984) (Chapter 15), and MT3D (Chapter 16) output files. Surface may also be used to display any regularly gridded data, from other sources, DEM's (Digital Elevation Model's) being a common example.

NOTE: contour can read both grid centered and node centered meshes, but node centered meshes are converted to grid centered meshes inside the application. This is necessary because of several internal algorithms. This has the effect of averaging the grid values slightly.

In order to make UNCERT run as smoothly as possible, surface was designed so that many of the various data formats created by other UNCERT modules, and some other commercial software, are compatible with the program, thus reducing continuous modifications often required to accommodate third party software.

The surface application is composed of five sections (Figure 12.1); the main menu-bar, the slider bar bulletin board, the surface orientation block (upper right), the log/status area, and the drawing or graphical area. The menu-bar is used to select all surface commands and the drawing area is the display area for the rendered surfaces. Four slider bars are present to shift the color palette, to tilt and rotate the surface, and to move the light source (These sliders are discussed in more detail in the Palette and View:Parameters menu sections below). In the orientation block, the left arrow points to map north, and the right arrow points towards the light source (This is only appropriate when a shaded relief view type is selected (discussed in View:View Type menu section)). The log/status area is used to display messages to the user about the programs status, and is available for the user to type in notes.

(12-1)Figure 12.1


Menu Items
Examples
Command Line Arguments
File Formats
Mathematics
Bibliography

The Main Menu:

The main menu controls nearly all the program operations; files can be opened and saved, graphics can be plotted, the appearance of the graphic can be modified, help can be requested, and the results can be sent to the printer. For surface there are eight items on the main menu: File, View, Gradient, Palette, Fonts, Plot, Log, and Help (Figure 12.1). File controls file handling (opening, saving, naming files), directs printing, and allows the user to quit the application. View defines how the surface will be rendered and the orientation of the viewer and the light source. Gradient is used to specify color values for slope gradients. Palette defines the current color palette and color scale range, and displays the color scale legend. Fonts controls the type and size of fonts used within the Labels dialog. Log controls the saving, viewing, and printing of the log/status window. Plot plots the graph. Help gives the user a selection of pop-up help topics. Each menu item is fully described below with all the available options.

[TOP] [SYNTAX]


File:

The File sub-menu options control file and print handling, and exiting the program. The options include Open, View, Save, Save as, Save Preferences, Print Setup, Print, Quit, and Quit Without Saving.

Open:

Selecting File:Open generates a pop-up dialog which allows the user to select an existing data file. This dialog operates exactly as the Open:File dialog in Chapter 5 (plotgraph Figure 5.2). However, unlike plotgraph the default data file extension is *.srf.

View:

File:View pops up a simple screen editor with the last saved version of the file being graphed.

Save Preferences:

When using programs with many user options, it is not possible for the program to always pick reasonable default values for each parameter or input variable. For this reason preference files were created (See Appendix C). These allow the user to define a unique set of "defaults" applicable to the particular project. When File:Save Preferences is selected, surface determines how all the input variables are currently defined and writes them to the file "surface.prf."

WARNING: if "surface.prf" already exists, you will be warned that it is about to be over-written. If you do not want the old version destroyed you must move it to a new file (e.g. the UNIX command mv surface.prf surface.old.prf would be sufficient). When you press OK the old version will be over-written! This cannot be done currently from within the application. To rename the you will have to execute the UNIX mv command from a UNIX prompt in another window.

If "surface.prf" does not exist in the current directory, it is created. This is an ASCII file and can be edited by the user. See Appendix C for details.

Print Setup:

File:Print Setup works exactly as explained in Chapter 5.

Print:

File:Print generates a Postscript file of the calculated spatial measure, and depending on how the print options are define in Print Setup, directs this file to the specified print queue, or to the specified file.

Quit:

File:Quit terminates the program, but if additions have been made to the graph, the user will first be queried to supply a file to save the changes in.

[TOP] [SYNTAX]


View:

The View options are used to control the rendering technique for the surface, the view orientation, scaling, light source parameters, and hidden line/grid removal options.

Active Plane:

When a three-dimensional grid file is loaded, this option becomes available. View:Active Planes allows the user to specify which plane of the grid will be displayed and contoured. The pop-up dialog shown in Figure 10.6 (Chapter 11 , contour) controls these options. The contour map can be cut along the X-Y, X-Z, or Y-Z Plane. Once the Plane orientation has been selected the Layer, Column, or active Row may be selected. Pressing the Previous or Next buttons will step surface through the selected planes. To determine which plane you want to select, refer to Figure 10.7 (Chapter 11, contour).

View Type:

There are four surface rendering techniques which are set using View:View Type:[Gradient] [Grid] [Filled Grid] [Shaded Relief]. Gradient generates a filled surface where the color coding is based on the slope or gradient of the surface at that location (Figure 12.2). Grid generates a fishnet or wire mesh surface (Figures 12.3a & 12.3b) with the colors representing elevation or the magnitude if the z variable. When using this view type "hidden" lines (lines are not visible because closer surface obstructs their view) can be used (lines or sections on lines not visible will not be drawn, Figure 12.3a) or turned off (Figure 12.3b). To set the use of hidden lines see the View:Parameters section on hidden line removal. For the remaining other types, hidden line removal refers to if the wire grid is drawn. For these other view types, the grid blocks are filled with a solid color based on elevation or z magnitude (Filled Grid, Figure 12.4), or obliqueness of the surface to the light source (Shaded Relief, Figure 12.5). On the shaded relief maps, surfaces being struck directly by the light source will be white, surfaces facing 180o from the light source will be black, and intermediately oriented surfaces will be colored with an appropriate shade of gray.

(12-2)Figure 12.2

(12-3a)Figure 12.3a and (12-3b)Figure 12.3b

(12-4)Figure 12.4

(12-5)Figure 12.5

Parameters:

In addition to defining the color coding of the surface map, it is useful to control the maps Exaggeration, view Angle Above Horizon, view Angle From North, Zoom, Sun Angle or light source direction, light source Brightness, Hidden Line Removal, and Drop Box. These parameters are defined in the pop-up dialog shown in Figure 12.6. To display this dialog, select View:Parameters from the menu-bar.

(12-6)Figure 12.6

Exaggeration controls the vertical exaggeration of the map surface. Exaggeration is a multiplicitive factor, therefore legal values are greater then 0.0; 1.0 will give the true relief, values between 0.0 and 1.0 will reduce the exaggeration, and values greater than 1.0 will increase the exaggeration. With many data sets it is useful to substantially increase or decrease this value. If the surface appear flat, the difference in z values is small compared to the horizontal distances; in this case the exaggeration should be increased. If the surface is tall and thin (in the extreme case a vertical line extending off the top and bottom of the screen) the exaggeration should be decreased.

The Angle Above the Horizon and the Angle From North refer to the viewers reference to the surface. In surface the viewer is always looking down on the map surface, and the Angle Above the Horizon describes viewers viewpoint as an angle above the horizontal; 90o is looking straight down on the surface (plan-view map), 0o is looking horizontally across the surface (valid values are 0o to 90o). The Angle From North defines the direction that the viewer is looking, i.e. to look to the north across the map surface the correct Angle From North angle would be 0o (valid values are 0o to 360o).

Zoom allows the user to zoom closer to (enlarge view), or further from (shrink map) the center of the map surface. The default is 1.0, with legal values greater then 0.0. Values greater than 1.0 will zoom closer to the surface, values less than 1.0 will zoom further from the surface.

The Sun Angle and the Brightness control the light source. The Sun Angle describes the direction from the surface map the light source; it is assumed the light source is on the horizon. Legal values are between 0o and 360o. A common direction used is 315o; this puts the sun to the northwest. Even though in the northern hemisphere, the sun will never be in this position, when surface maps are viewed in plan view (Angle From North = 0o, and Angle Above the Horizon = 90o) the eye will interpret the shading correctly so that mountains appear raised and valleys appear depressed. If the light source comes from the southeast (135o), the relief appears reversed. The Brightness makes the bright's brighter, and the darks darker. Valid values are greater than 1.0. This is useful particularly in areas of low relief, and modifying the brightness can accentuate minor surface features.

Hidden Line Removal is used in combination with View:Type. The option behaves slightly differently though depending on which view option is selected. When using the Grid view type "hidden" lines (not visible because closer surface obstructs their view) can be removed (lines or sections on lines not visible will not be drawn, Figure 12.3a) or viewed (Figure 12.3b). For the remaining view types, hidden line removal refers to if a wire mesh is drawn over the map. The grid blocks are filled with a solid color based on elevation, gradient, or obliqueness of the surface to the light source. On low relief surfaces, drawing the mesh can help define the surface texture, however, the mesh can hide the color of the grid blocks and thus still hide the surface texture.

NOTE: There are potential reasons to use, or not use, hidden line removal for the view type Grid. The map surface rendering is slightly faster when hidden line removal is not used, and if there is not much relief, this setting may be appropriate. If there is significant relief , the map can become cluttered (Figure 12.3b) as areas are overdrawn. At the cost of slowing the drawing rate slightly hiding hidden lines will eliminate this problem (Figure 12.3a).

WARNING: The hidden line removal algorithm (when using View:View Type:Grid) has some problems at angles near 0o, 90o, 180o, and 270o. When lines are drawn near vertical on the screen, the algorithm breaks down and the wire mesh rendering appears to be missing portions of line segments.

The Draw Drop Box option allows the user to add a "drop box" bottom to the base of the rendered surface showing the X and Y coordinates. This feature can be toggled on (Figure 12.2) or off (Figure 12.4) by pressing the Draw Drop Box toggle button.

[TOP] [SYNTAX]


Gradient:

Rather then viewing just contoured or a shaded relief surface, it is sometimes useful to examine the gradient or slope of that surface (Figure 12.2). Examining the gradient can be useful for identifying areas where there might be slope stability problems, ground water flow direction, or problem areas in the grid itself (The grid is interpolated from field data, and different algorithms can generate significant problems that bear no relation to the field data (Wingle, 1992)). Currently, in this package, the gradient can only be indicated by color coded block (no directional information, (Figure 12.2)). The, color coded arrow, and by variable length arrows options in Chapter 11 (contour) currently are not available.

NOTE: This menu option works slightly differently then the Gradient option in the contour module (Chapter 11). In surface to activate the gradient option, Gradient under the View:Type menu-bar option must be selected.

The gradient at a particular point is not explicitly known and therefore has to be extrapolated from the gridded data. To calculate a gradient vector three points are required (three points define a plane), but because the grid file uses rectangular cells four are used. This unfortunately over defines the plane and the gradient represents an averaged gradient over the cell. A complete description of how the gradient is calculated is presented in the Mathematics section in Chapter 11.

Gradient:Modify pops up the dialog shown in Figure 12.7. This dialog allows the user to specify values for the appropriate parameters. In the dialog, there is a color scale reference. The color scale range can also be extended or narrowed by modifying the Gradient Color Range Minimum and Maximum values. These values are, by default set to the minimum and maximum gradients found for the grid file. This is linear scale, and sometimes a few spots with very steep gradients dominant the color scale. By reducing the maximum gradient for the color scale (often significantly), low gradient zone are better defined, with minimal detail loss to the steep zones. If these values have been changed, or specified on the command line or in a preference file, when a new file is loaded the extents of the gradients are not recalculated. Pressing the Maximize Gradient Range button will recalculate and respecify the gradient range and color palette.

(12-7)Figure 12.7

When the gradient view type is activated, the default settings plot the gradients using coded filled blocks (this is non-directional information). The options allowing the use of arrows are currently not supported (Use contour (Chapter 11) if directional (arrow) information is needed).

[TOP] [SYNTAX]


Palette:

Palette:Set Palette and Palette:Color Legend are described in Chapter 11 in the Palette:Set Palette and Palette:Color Legend sections (Figure 10.15). NOTE: The White palette option is not available.

[TOP] [SYNTAX]


Fonts:

Fonts:Modify is largely described in Chapter 5 in the Fonts:Modify section (Figures 5.10 and 5.11), but the font selection for surface is slightly different (Figure 12.8). Different fonts may be selected for the Main Title, Annotations, the North and Sun Direction Arrow labels, and the Axes Division Numbers.

(12-8)Figure 12.8

[TOP] [SYNTAX]


Log:

The Log menu option is supplied to allow the user to save, view, or print all text which has been written to the log/status window by the program or added by the user (The log window is also a simple text editor). The options include View Log, Save, Save as, Clear, and Print. View Log, Clear, Save, and Save as are similar in operation to the menu options under File described above.

[TOP] [SYNTAX]


Plot:

Plot:Now and Plot:Refresh are described in Chapter 5 in the Plot:Now and Plot:Refresh sections.

[TOP] [SYNTAX]


Help:

Help works exactly as explained in Chapter 5 (plotgraph, Figure 5.15) Help section.

[TOP] [SYNTAX]


Example of Using surface:

Using surface is straight forward. Once a file has been loaded a surface rendering is generated; most of the program options control only the appearance and orientation of the surface rendering.

There are three methods to load a file in surface. The first is to execute surface from the UNIX prompt and open the file from the menu, the second is to pass the file as a command line argument, and the third is to define the file name in the program preference file. To open a file from the main menu, execute surface from the UNIX prompt:

> surface

Once in the application, select the File:Open menu option. The pop-up dialog shown in Figure 5.2 will appear. Select the desired file. Once a file has been selected the graph of the data will be drawn. To open a file from the command line, enter at the UNIX prompt:

> surface [optional arguments] filename

For example:

> surface dig.grd

will open the graph file shown in Figure 12.4, and

> surface -vt 2 -pl 1 dig.grd

will open the file and plot it with a gray palette using shaded relief (Figure 12.5). NOTE: in both Figures 12.4 and 12.5, other variables then those passed on the command line could have been defined. These variables could have been set using the menus, or using a preference file (Appendix C). A preference file is used to define user preferred variable default values. Every time surface runs, it searches the current working directory for the file surface.prf. If it exists, surface reads the file and sets the variables as specified. This is the third way to open a file, because one of the arguments in the preference file is the name of the surface file.

[TOP]


Running From the Command Line:

In many cases it is more convenient to run the application completely from the command line, or at least pass some parameter values in from the command line. The options listed below allow the user to accomplish almost anything that is possible from within the X-windows application from the command line (adding lines from different files is not currently supported). This feature can be useful when the user does not have a X-windows/Motif terminal available, or when many graphs need to be processed quickly, and the operation can be completed in batch mode without user interaction.

Syntax:

surface [-bt #.#] [-colcut #] [-csmax #.#] [-csmin #.#] [-db #] [-ex #.#] [-fnt1 " "] [-fnt2 " "] [-fnt3 " "] [-fnt4 " "] [-fnts1 #.#] [-fnts2 #.#] [-fnts3 #.#] [-fnts4 #.#] [-gdmax #.#] [-gdmin #.#] [-help] [-hl #] [-hz #.#] [-lgf " "] [-lpbm #.#] [-lpc #] [-lpd #] [-lpf ""] [-lph #] [-lplm #.#] [-lppsext " "] [-lpo #] [-lpq ""] [-lpr] [-lprm #.#] [-lps #] [-lptm #.#] [-pal " "] [-pl #] [-prf ""] [-rfh #] [-rt #.#] [-sn #.#] [-vp #] [-vpc #] [-vpl #] [-vpr #] [-vt #] [-zm #.#] [filename]

Meaning of flag symbols:

# = integer
#.# = float
" " = character string.
{} = variable is an array. Values must be seperated by a ',' and no spaces are allowed. Do not use the "{ }" symbols on the command line.

NOTES:

1). All parameters in [] brackets are optional.
2). Quotes must be used around character strings.
3). Filename, if given, must be listed last.
4). If no default is given, the feature is not currently supported on command line.

Flag Definitions:

-bt = brightness of light source default = 1
-colcut = cutoff colors outside palette range default = 0
0
1
=
=
False
True
-cmax = maximum color palette value default = data set maximum
-cmin = minimum color palette value default = data set minimum
-db = draw drop box default = 1
0
1
=
=
False
True
-ex = exaggeration default = 1.0
-fnt1 = main title font default = Helvetica-Bold
-fnt2 = secondary title font default = Helvetica-Bold
-fnt3 = arrow label font default = Helvetica
-fnt4 = axes division label font default = Helvetica
-fnts1 = main title font size default = 15.0
-fnts2 = secondary title font size default = 12.0
-fnts3 = arrow label font size default = 12.0
-fnts4 = axes division label font size default = 10.0
-gdmax = maximum gradient default = steepest gradient
-gdmin = minimum gradient default = shallowest gradient
-help = give this help menu
-hl = hide lines default = 1
0
1
=
=
False
True
-hz = viewing angle above horizon default = 25.0
-lgf = log file name default = "log.dat"
-lpbm = page bottom margin default = 1.5
-lpc = number of copies to print default = 1
-lpd = print destination default = 0
0
1
=
=
Printer
File
-lpf = print filename default = "junk.ps"
-lph = print header page default = 0
0
1
=
=
False
True
-lplm = page left margin default = 1.5
-lpo = print orientation default = 0
0
1
=
=
Portrait
Landscape
-lppsext = search extention for postscript files default = "*.ps"
-lpq = print queue default = "ps"
-lpr = print file at specified orientations
-lprm = page right margin default = 1.0
-lps = print output default = 0
0
1
=
=
Black & white
Color
-lptm = page top margin default = 1.5
-pal = user specified color palette file default = " "
-pl = color palette default = 0
1
2
3
4
5
6
7
=
=
=
=
=
=
=
gray
spectrum
spectrum (looped)
hue
hue (looped)
white
user defined
-prf = preference file name defalut = "contour.prf"
-rfh = screen refresh default = 0
0
1
=
=
On exposure
On update
-rt = viewing direction default = 45.0
-sn = direction to sun (light source) default = 315.0
-vp = show map scale defalut = 0
0
1
2
=
=
=
X-Y
X-Z
Y-Z
-vpc = active column view plane defalut = 1
-vpl = active layer view plane defalut = 1
-vpr = active row view plane defalut = 1
-vt = show map scale defalut = 0
0
1
2
3
4
=
=
=
=
=
fill grid
gradient
wire mesh grid
overlay (NOT AVAILABLE)
shaded relief
-zm = zoom default = 1.0

An example command might be (typed on one line):

surface -lpr -bt 1.0 -ex 0.15 -hz 25.0 -pl 1 -rt 45.0 -sn 315.0 -vt 2 -zm 0.7 dig.grd

This command produces the graph shown on the cover of the manual.

[TOP]


Setting up the Input File:

There are several data file formats readable by surface. These are discussed in the Setting up a Input Grid File section in Chapter 11. The file formats for contour and surface are identical.

[TOP]


Surface Mathematics:

In order to make the software package useful, sophisticated computer graphics algorithms are necessary to convert field and model data into images the computer monitor or the printed page that makes sense to the user. In this section some of the algorithms used in this software package will be discussed.

Rotations and Transformations:

The initial step in transforming the real world data coordinates is to translate them into screen, or planer, coordinates (Figure 12.9). Part of the translation has to consider the viewers location relative to the object of concern, and the second consideration is transforming the data into the two-dimensional plane of the computer monitor or the printed page. This process can be summarized as (Foley et al, 1990):

(12-1) (12-1)

where < x', y', z' > are the translated coordinates, < x, y, z > are the real world coordinates, is the rotation angle (about the Z-axis) from North, is the rotation angle from the horizon (about the X-axis), and R is a rotation matrix given by (Foley et al, 1990):

(12-2a) (12-2a)

(12-2b) (12-2b)

or an arbitrary rotation about the XZ axis is:

(12-2c) (12-2c)

and

(12-2d) (12-2d)

T is an arbitrary translating in the x, y, or z direction and is defined as (Foley et al, 1990).

(12-3a) (12-3a)

and

(12-3b) (12-3b)

and when combined with the rotation matrix R, yields:

(12-4) (12-4)

When T and R are substituted into equation 12-1 T' and R' are defined as the portions of matrix 12-4 defined as follows (Foley et al, 1990):

(12-5) (12-5)

By applying equation 12-1, all real world points in data set can be translated into screen coordinates. The screen coordinates, x', y', and z', can now be solved and reduce to:

(12-6a) (12-6a)
(12-6b) (12-6b)
(12-6c) (12-6c)

This transformation is called a parallel transformation which is described in the next section.

(12-9)Figure 12.9

Hidden Surface and Line Removal:

The computer monitor or the printed page are two dimensional surfaces on which many computer graphical techniques try to represent three-dimensional bodies. Part of the problem in this transformation is determining what portions of the bodies are visible or hidden from view. In some cases this can be a trivial process; if others it is complex and computationally very expensive. This techniques described below review some of the techniques used in this software package.

Parallel Transformation:

By translating world data coordinates into screen coordinates (with the z-axis pointing out of the display) the relationship of which objects are in front of others can be quickly determined (those with the highest z-value are the closest). Without the transformation; instead of only two comparisons (x1 = x2 and y1 = y2), four additional divisions are necessary; this is computationally expensive and should be avoided (Foley et al, 1990).

Back to Front Drawing:

List priority algorithms sort the objects so that they be drawn in the correct order from back to front; in this way objects further away are obscured as closer objects are drawn over them (Foley et al, 1990). This method works quite well unless an object can pierce or overlap and under lap another object. In the simple case, a Depth-Sort Algorithm may be used. The idea here is that, as the closer objects are drawn, they paint over objects to the rear which are not visible. Depending on the geometry of the data set the order may be simple to determine (as with a rectangular mesh, see block in chapter 13), or very complex (as with irregular finite-element meshes, see mesh (Incomplete package)).

Surface Shading With Shaded Relief:

The use of surface shading is a useful technique to characterize or aid in the visualization of a surfaces texture; it is also a useful technique for highlighting structural trends, and low-relief features. This technique mimics low-sun-angle photography, a popular remote sensing technique. One use in remote sensing is lineament analysis (Lillesand and Kiefer, 1987), and computer simulated shading can be used the same way. Computerized shading can mimic the sun's (light source) angle over the surface, or it can place the sun in positions that would never occur in nature. This can enhance features not otherwise observable.

The technique is rather simple. If the tangent vector to the surface points directly to (0o off sun angle) the light source (sun), that portion of the surface is colored white (It is receiving the maximum possible light from the light source). If the tangent vector to the surface points directly away (180o off sun angle) from the light source (sun), that portion of the surface is colored black (It is receiving the minimum possible light from the light source). Surfaces whose tangent vector lay somewhere in-between receive a proportionate amount or white light, or are assigned an appropriate gray value. The percent gray assigned for the surface location is defined as:

gray % = o's off angle to sun / 180.0o (12-7)

or

gray % = (cos (l - n) + ) / 2 (12-8)

where l is the light source vector, n is the vector normal to the surface, 0% gray = white, and 100% gray = black.

Slope-Gradient Determination:

As discussed in contour, this is an approximation method (See chapter 11, Slope-Gradient Determination section for details) for determining the slope or gradient of each cell within the grid.

[TOP]


Bibliography (surface):

Foley, J.D., A. Van Dam, S.K. Feiner, and J.F. Hughes, 1990, Computer Graphics, Principles and Practice, Addison-Wesley, Reading, Massachusetts.

Gómez-Hernández, J.J. and R.M. Srivastava, 1990, ISIM3D: An ANSI-C Three Dimensional Multiple Indicator Conditional Simulation Program, Computers in Geoscience, Vol. 16, No. 4, pp. 395-440.

Lillesand, T.M. and R.W. Kiefer, 1987, Remote Sensing and Image Processing, Second Edition, John Wiley and Sons, New York.

McDonald, M.G., and A.W. Harbaugh, 1984, A Modular Three-Dimensional Finite- Element Flow Model, U.S. Geological Survey OFR 83-875.

[TOP]


Table of Contents
Previous Chapter
Beginning of this Chapter
Next Chapter