G
E
O
F
O
R
M
U
L
A
S

Tutorial

Using Geospatial
Formulasin

TNTmipsÆ
TNTeditôTNTviewÆUsing Geospatial Formulas

Before Getting Started
This booklet introduces techniques for using GeoFormulasô in TNTmipsÆ,
TNTeditô, and TNTviewÆ. Geospatial objects from TNT Project Files can be
combined dynamically in the display process to achieve ìdata fusionî effects.
This booklet introduces you to the basic GeoFormula tools in the Display / Spatial Data and Process / GeoFormula processes.
Prerequisite Skills This booklet assumes that you have completed the exercisesin the tutorials Displaying Geospatial Data and Navigating. The exercises inthose booklets present basic skills and techniques for selecting and viewing
objects stored in Project Files, and getting around in TNTmips. Please consult
those booklets and the TNTmips reference manual for any review you need. You
will also find it helpful to complete the exercises in the Writing Scripts with SML
tutorial, since GeoFormula constructions use SML syntax.
Sample Data The exercises presented in this booklet use sample data that is
distributed with the TNT products. If you do not have access to a TNT products
CD, you can download the data from MicroImagesí web site. In particular, thisbooklet uses objects in the CB_DATA and GEOFRMLA data collections. Make a readwrite copy of these files on your hard drive; you may encounter problems if you
work directly with the read-only sample data on the CD-ROM.
More Documentation This booklet is intended only as an introduction to data

fusion with GeoFormulas. Consult the TNT reference manual on the 2D Display
and separate GeoFormula processes for more information.
TNTmips and TNTliteô TNTmips comes in two versions: the professional version and the free TNTlite version. This booklet refers to both versions asìTNTmips.î If you did not purchase the professional version (which requires asoftware license key), TNTmips operates in TNTlite mode, which limits object
size.

The GeoFormula feature is also available in TNTedit and TNTview. The exercises
can be completed in TNTlite using the sample geodata provided.
Keith Ghormley, 2 January 2004
It may be difficult to identify the important points in some illustrations without
a color copy of this booklet. You can print or read this booklet in color fromMicroImagesí web site. The web site is also your source for the newest
tutorial booklets on other topics. You can download an installation guide,sample data, and the latest version of TNTlite:
http://www.microimages.com

page 2

Using Geospatial Formulas

Introducing Geospatial Formulas
A GeoFormula is a computed display layer that uses
one or more input objects to derive a result for display. It gives you a way to combine objects ìon theflyî rather than running separate processes to prepare output objects for display. A GeoFormula is a
dynamic display layer that contains a ìvirtual object.î The GeoFormula layer does not create an output object that is saved in a
Project File. Instead, it creates a display layer that releases all its system resources (such as disk spaceand memory) when you arefinished with it.
For example, red and infrared bands of raster imagery
can be combined to produce a Transformed Vegetation Index (TVI). Of course
TNTmips offers a simple
process that produces a TVI output raster object
from selected input objects if you want to retain the
TVI output for other uses. But if you just want toview the TVI result and do not care to keep the output object, you can use a GeoFormula display layer.
(The exercise on page 6 provides a TVI GeoFormula
script.)A GeoFormula script can be saved as a reusable file.
A GeoFormula layer can be combined with any number of other layers in the TNTmips display process
to create a complex visualization of multiple geospatial objects.
The GeoFormula feature is primarily provided for
dynamic visualization tasks in the display process.
You can also run a separate GeoFormula process(Process / GeoFormula) to create permanent output
objects for other uses (see page 18).

page 3

One or more layers in adisplay may be dynamicallycomputed from a
GeoFormula that refers toseveral input objects.

Geoformula display layers
perform file access andmulti-object processing on
the fly. Thus you may
notice that this processing
overhead results in slower
display times that may seemsluggish compared to otherdisplay layers.

Simple one-object
GeoFormulas are introduced on pages 4 and 5.
Pages 6-12 present a
number of multi-raster
scripts. The exercises on
pages 13-15 show how to
combine both raster andvector objects in a single
GeoFormula.

Using Geospatial Formulas

A Simple GeoFormula
STEPS; open a new 2D
Display group; in the Group Controls
window select Add
GeoFormula Layer in themenu under the Add
GeoFormula icon
; select Formula / New in
the GeoFormula Layer
Controls dialog; select CB_DATA / CB_TM /TM_5 in the SelectObjects dialog; click the Show Details
toggle in the Objects tab
and select Auto
Normalize for contrast; select the Script tab andtype in ìTM_5î
; select the Output tab
and change the Type toGrayscale; click [OK] to close the
GeoFormula Layer
Controls dialog; click [No] in the Verify
dialog that asks if you
want to save changes

You add a GeoFormula layer just as you would add
any other display layer in the Group Controls window of the Display process. Click the Add
GeoFormula icon button to open the GeoFormula
Layer Controls dialog. The GeoFormula Layer Controls dialog lets you create a new GeoFormula oropen an existing one. Select New from the Formulamenu. Since a GeoFormula must refer to at least one
georeferenced object, the process prompts you toselect one or more input objects in the standard
Select Objects dialog. Select the TM_5 raster object
from the CB_TM Project File in the CB_DATA data collection, and click [OK] to close the Select Objects
dialog.
For this script, we will simply display the unmodified values of the TM_5 raster object in grayscale.
Select the Object, Script, and Output tabs in turnand make the changes illustrated below. When you
click [OK] after making the last change, the process
closes the GeoFormula Layer Controls dialog anddisplays the GeoFormula layer.
in the Script tab, a very simple
GeoFormula expression uses theunmodified values from TM_5.

Change theoutput type toGrayscale in
the Output tab.
The Objects tab shows you
the TM_5 input object. Turn on the Show
Details toggle and select Auto Normalize fromthe contrast menu.

page 4

Using Geospatial Formulas

Using Insert Symbol
For our next look at the GeoFormula controls, we will create aslightly more complex script.
Open the GeoFormula Layer
The GeoFormula icon button
Controls dialog by clicking theopens the GeoFormula
Layer Controls dialog.
GeoFormula icon button in thelayer list of the Group Controls
window. Repeat the steps from the exercise on page
4 to create a new GeoFormula (start with Formula / STEPSNew), and select the same TM_5 input raster object. ; repeat the steps fromthe previous exercise to
Set the contrast to Auto Normalize in the Objects
create a new script
tab, and the output type to Grayscale in the Output
with CB_TM / TM_5 inputtab.
; select Insert / Symbol
In the Script tab, open theInsert Symbol dialog byselecting Symbol fromthe Insert menu. In theInsert Symbol dialog,change the Type to Numeric. The process automatically lists the numeric variables available for the TM_5 input object.
Select TM_5_Value and click [Insert]. Put yourcursor in the Script panel and type in a plus operator(ì+î) after TM_5_Value, and then return to theInsert Symbol dialog and get the TM_5_X variable. Return to the Script tab and type in ì/4î tocomplete the expression. Your complete
GeoFormula should be
TM_5_Value + TM_5_X / 4

Click [OK] to close the GeoFormula Layer Controls dialog and view the result.
The TM_5_Value variable is a ìprocessedî value: thecell value adjusted for display by the selected
contrast table. The TM_5 value (used in the previous
exercise) is a ìrawî input cell value that is notaffected by the selected contrast table.

page 5; insert TM_5_Value fromthe Numeric symbol list
; edit the script andselect TM_5_X from thesymbol list to complete
the expression
illustrated

Adding TM_5_X / 4 to the
output value creates avignetting effect, increasing
display intensities as the X
coordinate value increases.

Using Geospatial Formulas

A Two-Band Vegetation Index
A .gsf file contains theparameters and definitions
used in a GeoFormula. It
automatically records thechanges you make in the
GeoFormula Layer Controls
dialog.
STEPS; select Formula /Open in the
GeoFormula Layer
controls dialog; select GEOFRMLA / TVI.GSF; select PHOTO_IR and REDfrom the CB_TM ProjectFile; if the background color
shows through in theview, turn off the Null
Cells transparent toggle
in the Output tab of the
GeoFormula Layer
Controls

The strength of the GeoFormula feature in the Display Process is that it lets you perform operations
on multiple input objects ìon the fly.î For example,
to view a Transformed Vegetation Index (TVI) result(showing vegetation vigor computed from near-infrared and red spectral bands), you could run Process / Raster / Combine / Predefined, select input
objects, create an output raster, and view the result.
By contrast, the GeoFormula feature lets you view
the TVI result dynamically in a ìvirtual object,î without running a separate process to create a rasterobject.
Open the GeoFormula Layer Controls dialog andselect Open from the Formula menu. Use the SelectObjects dialog to select the TVI.GSF script. The process opens the script and immediately puts you into
the Select Objects dialog, prompting you for the
input objects that the script wants. Select PHOTO_IR
and RED from the CB_TM Project File.
The TVI.GSF script scales the TVI value
with a multiplier of 100. If the display
looks too dark, edit the script toincrease the multiplier.

Grayscale output typeassumes an 8-bit data
range (values 0-255).
Always adjust theexpressions in yourscripts to scale thedisplay values into an
appropriate range for 8-bit
grayscale display.

Select PHOTO_IR and RED from CB_TM.

page 6

Using Geospatial Formulas

A First Look at Color
In the previous exercises, the GeoFormula scripts
have been simple expressions that yield numericvalues for grayscale display. When the output typeis grayscale, the numeric expression is used directlyfor 8-bit grayscale display intensity. (Always scale
grayscale GeoFormula values to the 0-255 range.)
When you change the output type to color, the process automatically creates three color component
variables: Output_Blue, Output_Green, and
Output_Red. For color output, your script must assign 8-bit values to each of the output component
variables.
For a simple case, open the GeoFormula Layer Controls dialog and select Formula / New. Select RED,
GREEN, and BLUE from the CB_TM Project File as input
objects, and Auto Normalize for each objectís contrast. In the Output tab, select Color for type. In the
Script tab, type in the script illustrated below. (You can use the Insert
Symbol dialog to pick the symbols
from a list.)

STEPS; Open the
GeoFormula Layer
controls dialog andselect Formula / New; select RED, GREEN, andBLUE from the CB_TM
Project File; select Auto Normalize
for contrast and Colorfor Output Type; type in the script
illustrated below

The simple script illustrated
here achieves the same
display result as the direct
RGB color display option in
the Display process.

The Insert Symbol list
automatically adjusts forcomponent color output.

Capitalization matters. Typein the script with exactly thesame use of upper and lower
case illustrated.

page 7

Using Geospatial FormulasBand Ratios for Composite Color
STEPS; open the
GeoFormula Layer
Controls dialog; select Formula / Openand select GEOFRMLA /NDTMRGB.GSF; for input, select the
CB_TM Project File; select BLUE, RED,
PHOTO_IR, TM_5, and TM_7
for the input objects as
prompted; click [OK] to close theSelect Objects dialog; click [OK] to close the
GeoFormula Layer
Controls dialog

The previous exercise showed how simple input
values and expressions can be assigned to RGB color
components in a GeoFormula. For a slightly more
complex example, we will use computed values for
RGB color components.
You may be familiar with the Normalized Difference
band ratio from an introductory image processing
course. (Also refer to the tutorial booklet Combining Rasters for a brief introduction to Normalized
Difference ratios.) A Normalized Difference ratio of
two bands can supply a value that can be used forgrayscale display, just as the TVI example did on
page 6. In this exercise, we use 6 bands in 3 ratios toproduce values for RGB component display. The
TM imagery in the CB_TM Project File can be combined for: Red: TM_5/TM_7 (which shows bare soils
bright, green vegetation dark), Green: RED/BLUE(which shows iron-stained soils
bright, green vegetation dark), andBlue: PHOTO_IR /RED (whichshows vegetation bright).
Use Formula / Open to selectNDTMRGB . GSF and select the TM
bands from CB_TM as prompted.
The NDTMRGB.GSF script result showsbright green to yellow values in nonvegetated areas. Fields with healthy
crops are dark blue, while grassy
pasture and fallow fields appear pink
to brown.

page 8

Using Geospatial Formulas

Open the Brovey GeoFormula
A more complex use of color implements the Brovey
transform to enhance low resolution color imagery
with high resolution grayscale imagery. Open the
GeoFormula Layer Controls dialog, select Formula /Open, and select BROVEY1.GSF in the GEOFRMLA datacollection.
BROVEY1.GSF enhances the display of three color
component bands of low resolution imagery by using one band of high resolution grayscale imagery.
The sample data in the CB_TM Project File offers 7
bands of 30-meter TM imagery, while the CB_SPOT
Project File contains 1 band of 10-meter SPOT imagery. The GeoFormula can combine TM with SPOT
for a synthetic 10-meter resolution for the color TM
data.

Select PHOTO_IR, RED, and GREEN from CB_TM for the
Select CB_SPOT /SPOT_PAN for the HIGHRES input.
RED , GREEN , and BLUE inputs.

STEPS; open the
GeoFormula Layer
Controls window; select Formula / Open in
the GeoFormula Layer
Controls window; use the standard SelectObjects process toselect GEOFRMLA /BROVEY1.GSF; for input, select the
CB_TM Project File and
PHOTO_IR, RED, and GREEN
for the input objects; select CB_SPOT / SPOT_PAN
for the HIGHRES input
object; select the Preview tab
to see a quick rendering

A full redraw may be slow forcomplex scripts that use large
input objects. The Preview tab
offers a small, quicker
rendering.

The cursor
in thePreviewpane draws
a zoom box.

Zoom inand out
with the +
and ñ
keys.

page 9

By default, the GeoFormula
process treats only theoverlap area of input objects
that have different spatial
extents. Thus, the display
confines the extents to thesmaller area of CB_SPOT anddoes not show the wholearea of CB_TM.

Using Geospatial Formulas

The Brovey GeoFormula Results
The Brovey formula is quite
simple. Assume a RGB
display of bands B5, B4,
B2 (such as the TM bands
4, 3, 2) being sharpened
with band S1 (such as
SPOT). The formula is:
R = B5 / (B5+B4+B2) * S1
G = B4 / (B5+B4+B2) * S1
B = B2 / (B5+B4+B2) * S1Some simple algebraic
equivalence manipulations
and the introduction of ascale factor (to improve
display intensity) can beobserved in the form of the
BROVEY1 script illustrated
below.

The Display process renders the BROVEY 1. GSF
GeoFormula layer in the Group View window. Use
the standard zoom and position tools to examine thedisplay image. For comparison, open a second groupview and add the same three TM input images as an
RGB raster layer to compare the display results. As
illustrated below, the Brovey GeoFormula (left)
shows greatly enhanced feature detail compared tothe straight TM RGB image (right).
The Brovey transform does two things. First, it normalizes the data by dividing the band being displayed by the summation of all bands being displayed. Second, it sharpens the image by multiplying the normalized result by the high resolution data.
The implementation in the TNTmips GeoFormula also
multiplies by a scale factor to increase display intensity.

The Brovey GeoFormula takes color information from the low-resolution TM images andfeature detail from the high-resolution SPOT image and automatically presents a color
image with simulated high resolution. Left: Brovey result. Right: TM/SPOT inputs.

page 10

Using Geospatial Formulas

Brovey Enhancements to Band Ratios
Our last exercise in this progression shows some ofthe powerful complexity of the GeoFormula layer by
combining the band ratio computations from the exercise on page 8 with the Brovey resolution enhancement (pages 9 and 10).
Use Formula / Open to select NDRATBRV.GSF and select the TM bands from CB_TM.RVC as prompted. The
script applies the TM5 / TM7, TM3 / TM1, and TM4/ TM3 ratios to the low resolution TM bands, andthen multiplies the result by the SPOT image to get
the high resolution enhancement.
Look at the script for the basic Brovey GeoFormula(page 10) and for the band ratio GeoFormula (page8) and observe how the two were combined for thisscript. The first three lines come with only slight
modification from NDRGB.GSF, while the last four lines
come from BROVEY1.GSF. In the same way, many complex GeoFormulas can be built from simpler scripts,
and the wise user will develop
and test GeoFormula components in simple scripts before
using them in complex scripts.
The NDRATBRV.GSF script combines
the Normalized Difference ratio
computations on lower resolution
TM bands with the Brovey
resolution enhancement from thehigher resolution SPOT image. The
result shows the spectral
information from TM sharpened by
the resolution information from
SPOT.

page 11

STEPS; open the
GeoFormula Layer
Controls dialog; select Formula / Openand select GEOFRMLA /NDRATBRV.GSF; Select BLUE, RED,
PHOTO_IR, TM_5, and TM_7
from the CB_TM ProjectFile; select SPOT_PAN from
CB_SPOT; click [OK] to close theSelect Objects dialog; click [OK] to close the
GeoFormula Layer
Controls dialog

Using Geospatial Formulas

A Saturation Stretch
STEPS; open the
GeoFormula Layer
Controls dialog; select Formula / Openand select GEOFRMLA /STRETCH2.GSF; for input, select RED,
GREEN, and BLUE from
CB_TM
; click [OK] to close theSelect Objects dialog; click [OK] to close the
GeoFormula Layer
Controls dialog

A GeoFormula layer can be used to apply color conversion manipulations. In this example, RGB input
components are converted to the equivalent HIS(Hue-Intensity-Saturation) values. Then a logarithmic stretch is applied to saturation values and the
HIS components are converted back to RGB values
for display. The new RGB set has brighter, more
vivid colors than the subdued colors in the original.
An HIS saturation stretch has an advantage overalternative RGB manipulations. When RGB manipulations are used, they often create problems of color
drift (such as red hues drifting towards orange). By
way of contrast, HIS manipulations make it easier tobrighten colors without changing their hue.
Follow the steps listed on this page to view the
STRETCH2.GSF GeoFormula.

TM3, TM2, TM1
with normalized
contrast.

TM3, TM2, TM1
after saturation
stretch.

You can change the valueof the multiplier in thesecond line to increase or
decrease saturation
stretch.

page 12

Using Geospatial Formulas

Vector Objects in GeoFormulas
Vector objects can be used in a GeoFormula. Whenyou select a vector object as input, you can accessthe object coordinate values in the form object_x
and object_y. You can also access values fromassociated attribute tables in the form
OBJECT.poly.TABLE.FIELD,OBJECT.line.TABLE.FIELD, and
OBJECT.node.TABLE.FIELD.
Note: precise use of upper and lowercase is essential. If a table is named in uppercase characters, as inìYIELD,î then the process will not find it if you use
lowercase characters, ìyield.î Likewise, the element
type keywords must be entered in lowercase: ìpoly, îìline,î and ìnode.î
Create a new GeoFormula for grayscale output andaccess the CBSOILS_LITE YIELD_OATS table for polygons as illustrated (exact uppercase/lowercase).
CBSOILS_Lite.poly.YIELD_OATS.OATS * 5

The surest and easiest
way to specify theelements in an attributetable is to insert them fromthe Insert Field dialog.

A multiplier of 5 is used to boost
the intensity for grayscale display.

page 13

STEPS; open the
GeoFormula Layer
Controls dialog; select Formula / Newand select CB_DATA /CB_SOILS / CBSOILS_LITE as
the single input object; select the Script tab in
the GeoFormula Layer
Controls dialog and typein the expression
illustrated (use theInsert Field dialog to pickthe field name); select the Output tab
and change the output
type to grayscale; click [OK] to close the
GeoFormula Layer
Controls dialog

Using Geospatial Formulas

Using Both Vectors and Rasters
STEPS; open the
GeoFormula Layer
Controls dialog; select Formula / Newand select CBSOILS_LITE
and TM_5 as input; type in the script
illustrated; change the output typeto grayscale, turn on the
Null Cells Transparent
toggle, and view theresult; select Formula / Openand select YIELD431.GSF
with CB_TM and
CBSOILS_LITE inputs; click [OK] to close the
GeoFormula Layer
Controls window

The GeoFormula feature offers a great deal of potential for complex combinations of objects of different types. You can construct an endless numberof expressions and statements that reference attributes and values from multiple input objects ofdifferent types.
In this exercise the CBSOILS_LITE vector object is combined with one band of the TM imagery from CB_TM.
The vector expression is similar to the expression in
the previous exercise, with the addition of a conditional structure. Make a new GeoFormula forgrayscale output, select TM_5 and CBSOILS_LITE for
input, and type in the expression
if (CBSOILS_Lite.poly.YIELD_OATS.OATS > 0)
TM_5_Value else 255

That expression works like a mask, taking the display value from TM _5 except where the
YIELD_OATS.OATS value is zero.
For a more complex GeoFormula, open YIELD431.GSF
which displays the YIELD_OATS.OATS values where
they are larger than 1, and the composite color 431
bands of TM imagery elsewhere.
The # character marks a line as a comment.
Use # to make the process ignore a line.

The color composite image of Crow Butte TM
bands 431 is visible where YIELD_OATS.OATS
has no value. The color spread is achievedby assigning the same value to the red andgreen output color components. Modify the
script to remove a different color component
and view the effect.

page 14

Using Geospatial Formulas

Universal Soil Loss Equation (USLE)The Universal Soil Loss Equation is used to createa soil erosion map from data that include conservation practices, soil types, surface slope, and rainfall
amounts. The basic form of the equation is:
A = R * K * LS * C * P
A GeoFormula script (USLE.GSF) implements the Universal Soil Loss Equation for the Crow Butte map
quadrangle. It uses the CBSOILS_LITE vector object
to access soil erodibility (K = LAYER.kfact) andslope-length factor (LS = COMPON.slopel). It uses
three raster objects for the remaining inputs: RAINFALL (R), MANAGEMENT (C), and CONSERVATION (P), allfound in the CB_DATA / LANDUSE Project File.
The resulting display layer is a grayscale map oferosion effects. Darker areas indicate lower erosion, and bright areas show higher soil loss.

STEPS; open the
GeoFormula Layer
Controls dialog; select Formula / Openand select GEOFRMLA /USLE.GSF; select input rasters
LITEDATA / CB_DATA /LANDUSE / RAINFALL,MANAGEMENT, andCONSERVATION; select input vector
object LITEDATA / CB_DATA /CB_SOILS / CBSOILS_LITE; click [OK] to close theSelect Objects dialog; click [OK] to close the
GeoFormula Layer
Controls dialog

Follow the steps listed on this page and run the
USLE script. You can modify the script to brighten
the grayscale display by adding a multiplier after the Rainfall factor.

USLE.GSF is a good candidate foruse in the stand-alone
GeoFormula process (Process /GeoFormula). You can examine
the output raster object toquantify erosion estimates, andcreate color maps for display.

Remove the USLE GeoFormula layer before going on to the next exercise.

page 15

Using Geospatial Formulas

Background Layers and DataTips
STEPS; add PHOTO_IR and
GREEN as background; open the Raster Layer
Display Controls dialog
and define DataTips forboth background layers; deselect the Hide/Show
checkbox in the
LegendView for bothbackground layers; turn on DataTips for all
layers with Options /DataTips / All Layers; click Add
GeoFormula andselect DIVIDE.GSF with
PHOTO_IR and GREEN as
input; open the GeoFormula
Layer Controls dialog
and increase the Scalevalue in the Values tab
for brighter display

The TNTmips Raster Combinations process (Process / Raster / Combine / Predefined) offers a number of standard ìraster algebraî manipulations.
GeoFormulas have been prepared to duplicate manyof these combinations (refer to page 8). You canenhance your use of GeoFormulas by using
DataTips with background layers or multiple Views
to examine the input values for the GeoFormula.
For this exercise, we will display a simple grayscale
band ratio (refer to the tutorial Combining Rasters,
page 5). Add PHOTO_IR and GREEN from the CB_TM
Project File as background layers. Define a DataTip(Internal.Value) for each layer with the Raster Layer
Display Controls dialog, and deselect both Hide/Show checkboxes in the LegendView. Turn on
DataTips for all layers with Options / DataTips / All
Layers in the View window.
Click the Add GeoFormula icon tool, and select
DIVIDE.GSF, with GREEN and PHOTO_IR for the A and B
input objects. Adjust the
Scale value in the Values
tab in the GeoFormula
Layer Controls dialog tobrighten the grayscale display.

DataTips fromthe PHOTO_IR
and GREEN
backgroundlayers show
the input
values usedby DIVIDE.GSF

The Internal.Value
DataTip shows the cellvalue of the raster layer.

Define a prefix so the
DataTip will show a layer
identifier with the cell value.

page 16

Using Geospatial Formulas

Interactive Script Development
The GeoFormula feature provides a usefuldeveloperís environment. It is an excellent place towork as you begin to assemble the pieces of a
GeoFormula, SML script, or even an APPLIDAT. By
using the GeoFormula feature, you can see the results of script changes immediately.
Build and test pieces of a larger develpment project
as a GeoFormula and then, when you are satisfied
with the results, select Save As from the Formulamenu. The Save As option creates an output text
file that you can incorporate into an SML script, or
modify to invoke from SML as an $include file.
You can also use a GeoFormula for interactive debugging of a script you have been developing in the
SML process. For example, if you are getting resultsfrom an SML script that seem to be wrong, look forpieces of the script that could work as a GeoFormula.
Then create a quick GeoFormula script to test eachpiece and view the results it produces. Select Insert
File from the Edit menu and select any SML script.

STEPS; click Add
GeoFormula / Add
GeoFormula Layer; choose New from the
Formula menu
; select LITEDATA / CB_DATA /CB_TM / RED as a single
object to process; select the Script tab andchoose Insert File fromthe Edit menu
; select LITEDATA / SML /SCALE.SML; make the editingchanges illustrated
below and click thePreview tab

Consider the differences between the SML and
GeoFormula environments, and be sure to make appropriate changes to the GeoFormula.

The SCALE.SML script in
the SML editor

Edit the script to adjust it for the
GeoFormula environment. Observe
the changes illustrated.

Select Edit / Insert File to get the SCALE.SML script into the GeoFormula Script panel.

page 17

Using Geospatial Formulas

Saving GeoFormula Output
The Output panel lets you
specify options for the
output raster object.

Pre-processing a
GeoFormula reduces
rendering time in the display
process.

The TNTmips GeoFormula Object Combinations
process (Process / GeoFormula) lets you save
GeoFormula output as a raster object in a ProjectFile. You may want to save GeoFormula results as araster object after you have used interactive techniques to refine a complex
GeoFormula in the display process. You
may also want to gain the speed benefits of preprocessing rather than waiting for a complex GeoFormula to re-process its input objects every time a View
is rendered. A single raster layer typically displays in less than one second,
whereas most GeoFormula layers take acouple of seconds or more to display.
The GeoFormula Object Combinations window differs from the GeoFormula Layer Controls window,
in that it has no Preview tab, and that the Output
panel lets you specify output raster options.

A GeoFormula renders TM bands for Crow Butte in CIR
and shows green soil map polygons with partial
transparency based on the yield.oats attribute.
LEFT: as a GeoFormula layer: 5 seconds
RIGHT: processing: 7seconds, display: <1 second.

page 18

Using Geospatial Formulas

Speeding Up GeoFormula Display
Geoformula display layers perform file access andmulti-object processing on the fly. This processing
overhead results in slower display times that may
seem sluggish compared to other display layers.
This exercise introduces some standard programming techniques that help reduce display times.
Use the Preview Pane. The Preview pane in
the GeoFormula Layer Controls window presents asmall preview image quickly. Use the Preview pane
especially as you compare the effects of different
variable values and other script changes during development.
Reduce the View Window Size. Just as thesmall image in the Preview pane displays quickly,
so does a small View window. The GeoFormula process samples its input objects according to the sizeof the View window, so a small View results in lessinput data to process.

Display times vary with thecomplexity of the
GeoFormula and the size
and number of input objects.
The comparison times listed
below show only sample
speed improvements.

Preview pane: 1 second
View window: 3 seconds

Small View: 2 seconds
Large View: 9 seconds

scale = 3 * HIGHRES_Value / (RED_Value +GREEN_Value + BLUE_Value + 1);
Calculate Values Once.
Output_Red = RED_Value * scale;
Find ways to optimize your
Output_Green = GREEN_Value * scale;
script. See if you can preOutput_Blue = BLUE_Value * scalecalculate a value so that it
BROVEY1.GSF computes the scale value once at theis derived once rather than beginning rather than in each output statement.
repeatedly. For example, inWith scale: 3 seconds
BROVEY1.GSF (see p. 9), a scale variable is calculated
Without scale: 4 seconds
once rather than with each output statement.

Use Nested If/Else. Test multiple logical conditions with nested if/else
if ((SPOT_PAN >=36) and (SPOT_PAN < 47)) 128
statements, always putting else if ((SPOT_PAN >=32) and (SPOT_PAN < 36)) 86
the most likely cases first else if ((SPOT_PAN >=47) and (SPOT_PAN < 50)) 170
and the least likely cases else if ((SPOT_PAN >=19) and (SPOT_PAN < 32)) 42
last. When the script en- else if ((SPOT_PAN >=50) and (SPOT_PAN < 54)) 212
else if (SPOT_PAN < 19)) 0
counters a true condition, it else if (SPOT_PAN >= 54) 255
skips the rest of the condiNESTEDIF.GSF puts higer-probabilty conditions earlier.
tions. By contrast, if you
use a simple sequence of if statements, the process Likely first: 4 seconds
Likely last: 6 seconds
tests every condition, every time.

page 19

Advanced Software for Geospatial Analysis

Using Geospatial Formulas

MicroImages, Inc. publishes a complete line of professional software for advanced geospatial datavisualization, analysis, and publishing. Contact us or visit our web site for detailed productinformation.
TNTmips TNTmips is a professional system for fully integrated GIS, image analysis,
CAD, TIN, desktop cartography, and geospatial database management.
TNTedit TNTedit provides interactive tools to create, georeference, and edit vector, image,
CAD, TIN, and relational database project materials in a wide variety of formats.
TNTview TNTview has the same powerful display features as TNTmips and is perfect for
those who do not need the technical processing and preparation features of TNTmips.
TNTatlas TNTatlas lets you publish and distribute your spatial project materials on CDROM at low cost. TNTatlas CDs can be used on any popular computing platform.
TNTserver TNTserver lets you publish TNTatlases on the Internet or on your intranet.
Navigate through geodata atlases with your web browser and the TNTclient Java applet.
TNTlite TNTlite is a free version of TNTmips for students and professionals with small
projects. You can download TNTlite from MicroImagesí web site, or you can order
TNTlite on CD-ROM.

Index.gsf file ................................................ 6
APPLIDATs .................................... 17
attributed tables ................................ 13
background layers ............................. 16band ratios .................................... 8, 11
Brovey transform ................... 9, 10, 11
color output ........................................ 7
data fusion .......................................... 2
DataTips ........................................... 16
GeoFormula Layer Controls ............... 4
GeoFormula standalone process ....... 18
GeoFormula ........................................ 3grayscale output ................................. 6
Insert Field dialog ............................. 13
Insert Symbol ..................................... 5
normalized difference .......................... 8null cells transparent ........................... 6
objects tab ........................................... 4
optimizing display times .................. 19

Output tab .......................................... 4
output_blue, output_red, output_green .. 7

preview pane ................................ 9, 19
raster/vector combinations ................ 14
resolution enhancement .................... 11
sample data ......................................... 2
saturation stretch .............................. 12
saving GeoFormula output ............... 18
script development ..................... 17, 19
script tab ......................................... 4, 5
SML and GeoFormulas .................... 17
Transformed Vegetation Index ............ 3
TVI ................................................. 3, 6
Universal Soil Loss Equation ............ 15
USLE ................................................ 15
vector objects .................................... 13
vector/raster combinations ................ 14
vegetation index .................................. 6¤

MicroImages, Inc.
11th Floor ñ Sharp Tower
206 South 13th Street
Lincoln, Nebraska 68508-2010 USA
Voice: (402)477-9554
FAX: (402)477-9559

page 20

email: info@microimages.com
Internet: www.microimages.com

E
D
I
T
R
A
S
T
E
R
S