A GIS Analysis of the Plausibility of Steady-State
Landscapes and the Colorado Plateau
CEE GIS-Water Resources Term Project
Fall 2002

Rob D Mackley

UTAH STATE UNIVERSITY
GEOLOGY DEPARTMENT


Table of Contents

Introduction

Understanding the erosional and tectonic dynamics of the Colorado Plateau (Fig 1) is a continuous work in progress.  Much previous work has been focused on understanding uplift and erosion rates and how theses rates vary in space and time.  At the same time, other workers have studied other landscapes with different erosional and tectonic histories.  A popular debate in recent years has been over the idea of landscapes which are in a so-called "topographic steady-state" (Montgomery, 2001; Pazzaglia and Brandon, 2001; Whipple, 2001; Bull, 2002).  A steady-state interpretation\assumption allows one to simplify equations and reduce the variables necessary in an attempt to numerically model the evolution of a landscape (Whipple and Tucker, 1999).

As part of a bigger project to understand the Cenozoic (65 Ma to Present) landscape evolution of the Colorado Plateau, an investigation into the plausibility of topographic steady-state conditions existing for the Colorado Plateau is an important preliminary measure.  The results of such an investigation have important implications.  In the case that results indicate a "non-steady-state" condition, the steady-state assumption will be violated and to some degree the results of the model will be viewed as less reliable.  It is to this end that this project will attempt to make a preliminary interpretation on the plausibility of topographic steady-state existing for landscapes on the Colorado Plateau.
 
 

Picture of Colorado Plateau
Fig 1.  Base map of Colorado Plateau


Project Outline

The scope of this project encompasses two main objectives:

1)    Encode a toolset to be used in ArcMap.

This will enable the investigation of steady-state plausibility by analyzing slope and contribution area from digital elevation models.  By creating this toolset, current and future steady-state analyses will take far less time and be much more automated and uniform.  The toolset will be written in Visual Basic and used as a macro within the ArcMap's Visual Basic Editor.

2)    Test steady-state plausibility for the Colorado Plateau.

With the newly created toolset, slope-area relationships will be used as a signal for steady-state topography for the Colorado Plateau.  Montgomery (2001) has recently shown that one desirable method for distinguishing steady-state landscapes is by looking at the relationship between drainage area and slope within a landscape.  Comparisons of theoretical to observed slope-area plots will be made to test for steady-state.
 

Developing the Toolset in Visual Basic

Previous analysis of slope-area relationships using manual means of extracting and tabulating grid cell values has proven to be very tedious, not to mention time intensive.  For this reason, the creation of a toolset which would speed this process up and allow more time to be spent interpreting results is very important and worth the time spent in developing it.  The entire toolset was programmed in Visual Basic code using ArcObjects.

The toolset contains three main tools or steps: tabulation of grid cell values, combining of text files, and binning and averaging.


Fig 2.    Main menu for Steady-State toolset showing the icons leading through the three-part process using slope and area grids.

Tabulating GRID Values

NOTE:  Prior to running this step, you need to have slope and area grids for your landscape.  These are commonly created using the Spatial Analyst extension and TauDEM software utility for slope and area respectively.  In my analysis I chose to use the D-infinity technique for computing contributing area.

The first step is to extract the grid cell values and output a tabulated text file containing a single column with rows of grid cell values.  This step is necessary in order to eventually plot values from the slope GRID against the area GRID cell values.  The details of the code can be found in the Appendix.


Fig 3.    Tabulate GRID cell values form showing user inputs pointing to the desired file and the scaling factor option.

As you may see in the code located in the Appendix, this subroutine goes through a series of steps in reading the values contained in the GRID and then writing them to a specified output text file composed of one, single column.


Fig 4.    Illustration showing the order in which the code extracts GRID cell values, searching every row then moving on to the next column.

This subroutine is run one time for each slope and area GRID, creating two  separate output files.  It is worth mentioning that this tool could be run on any type of  GRID.  For example one could just as easily analyze other morphometric parameters such as aspect or elevation.

Two To One, Combining The Two Text Files

NOTE:  This step assumes you have already created two separate text files using the Tabulate tool.  They need to contain only one column of data.


Fig 5.    User input form allowing one to select the two input files.  Clicking on the Create icon will prompt the user for the output filename and path.

This is handy tool that combines the two text files into one, two column file.  This is a necessary step if you want to plot one variable against another variable in some spreadsheet or graphing application.  You can simply import the output text file as a "comma-deliminated text file".  The actual code for this subroutine is located in the Appendix.  Basically, the code begins by opening up the two input files.  It reads them both and writes pairs of area and slope values to a specified output file sequentially.  It is important to mention that if your output text file contains more than 65,000 rows of data, Microsoft Excel cannot be used due to a row limit restriction in Excel.

Log Binning and Averaging


Fig 6.    User form for log binning the area values and averaging slope values within these bins.

In analyzing the relationship between slope and area it is common to bin area into 0.1 log units and average the accompanying slope values falling within individual area bins (Tarboton et al., 1992; Montgomery, 2001).  Originally, this was intended to be done in Excel since this program has within it functions which perform this operation with minimal effort by the user.  However, the 65,000 row limit made this impossible.  One workaround would be to sample the data.  But by lowering the total number of data points in an effort to squeeze them into Excel, the robustness of the data set might be compromised.  For this reason, the Log Bin Averaging tool was created.  Again, one may find the raw code located in the Appendix.

Due to my inexperience in programming, the only way I could code this subroutine ended up being far more complicated than is probably necessary.  The subroutine opens up the two column slope-area text file.  In a series of three to four iterations, depending on how large the area values are, the program will find the average and standard deviation of slope for each 0.1 log unit bin of drainage area.  The end result will be several output files.  One can then open these up separately and copy and paste them into one, single file which is ready for plotting.


Fig 7.    Final output file containing slope statistics for each 0.1 log unit bin of area.

This data can then be used to make x-y scatter plots in the software of your choice.  At this time I am unable to work the bugs out of the code written to do the plotting right in ArcMap.


Fig 8.    Scatter plot illustrating relationship between slope and area.

Testing Steady-State Plausibility for the Colorado Plateau

Background

The Colorado Plateau is a tectonic and physiographic province within the Rocky Mountain corridor of western North America (Fig 1).  The geology of the region consists of  Proterozoic (2.50 - .545 Ga) crust overlain by about 1.5 km of Paleozoic (545 - 245 Ma) sediments which are in turn overlain by a variable thickness of Mesozoic  (245 - 65 Ma) strata (Spencer, 1996).  The more recent, Cenozoic erosional and tectonic histories have been the basis for much debate.  It is however understood that this region has been subject to uplift during the Early to Middle-Late Cenozoic of at least 800 m (Pederson, et. al., 2002).  Any visitor to the Grand Canyon would observe that there has also been a significant amount of erosion to the landscape.

It is also important to mention the applicability of slope-area relationships to such a study of steady-state topography.  First of all, steady-state in a topographic sense is simply the notion that rates of uplift and erosion are very close if not equal, resulting in a landscape with a mean surface elevation staying quasi-constant through some specific time scale.  Montgomery (2001) used slope-area relationships as a simple test for steady-state.  Using physical laws (Appendix) describing the processes of erosion, a theoretical curve of this slope-area relationship can be generated assuming erosion and uplift values are equal, i.e. topographic steady-state.


Fig 9.    Predicted curve showing relationship between slope and area. (From Montgomery, 2001)

In this relationship, slope is expected to show a marked increase with increasing area.  There is a critical drainage area corresponding to a shift in erosion from hillslope type processes to stream channel processes.  By comparing plots generated from observed landscapes to this predicted curve, one can create a simple test for steady-state signatures.  If observed plots closely resemble this curve,  then one can argue that these landscapes are in a topographic steady-state.

Representative Study Sites

Three study sites were chosen; Hanksville, UT area (Fig 10), Book Cliffs, UT area (Fig 11), and a region located on the Uncompahgre Plateau, CO (Fig 12).  These were all chosen due to their characteristic landscapes that well represent the overall characteristics of the Colorado Plateau.   These landscapes are typified by having steep cliffs, flat topped mesas and plateaus, arid climates, little vegetation, and ephemeral streams. For the Hanksville and Book Cliffs study sites 10m DEMS were obtained.  Unfortunately only 30m data was able to be obtained for the Uncompaghre Plateau study site.

Fig 10.    Map of Hanksville, UT area study site.


Fig 11.    Map of Book Cliffs, UT area study site.

Fig 12.    Map of Uncompahgre Plateau, CO area study site.

Methods

    Obtain and Prepare Data:  The data used in this study were obtained from the GIS Data Depot (http://www.gisdatadepot.com) for no charge.  10 and 30 meter DEMs were downloaded and converted from SDTS to ArcInfo GRID format using the ArcToolbox.

    Construct Slope and Area GRIDS:  Using the Spatial Analyst extension in ArcMap, a slope GRID was created with values being represented in percentages.  TauDEM was used to generate a D-infinity flow accumulation GRID.  Contributing area values are reported in units of specific catchment area.  Specific catchment area being the value of area per unit contour width (Tarboton, 1997).

    Apply the Toolset:  Run the Tabulate Area, Two To One , and Log Binning and Averaging tools to the slope and area GRIDS.  This process generated the final output file containing the average and standard deviation of slope for each 0.1 log unit bin of drainage area.

    Plot:  Using MS Excel, the slope-area data were plotted as an x-y scatter plot with area and slope on the x and y-axes respectively.

    Compare:  The generated plots were visually compared to the theoretical reference curve predicted by physical erosion laws.

Results:

It was observed that slope-area relationships from all three study sites do not follow the predicted curve very closely (Figs 12, 13, & 14).


Fig 12.    Scatter plot showing slope-area relationship for Hanksville, UT area.  Notice slope values actually show an increase with greater area for high drainage area values.


Fig 13.    Scatter plot showing slope-area relationship for Book Cliffs, UT area.  Slope values do show a decrease as area increases but show variation in the high drainage area values region of the plot.


Fig 14.    Scatter plot showing slope-area relationship for Uncompahgre Plateau, CO area.  Slopes do decrease systematically as drainage area increases but data gradually show considerable variation as drainage area increases. NOTE:  30m GRID cells were used rather than 10m due to availability issues.

Discussion

While none of the study sites seem to show slope-area relationship curves looking identical to the predicted curve, they do show the same general trends.  Slopes do sharply increase with drainage area initially and then decrease systematically for the most part.  This is interpreted to coincide with the expected hillslope to stream channel process domain transition.

The Book Cliffs study site slope-area relationship resembles the predicted curve the closest.  This landscape within this defined study region is dominated by steep sloped plateaus and highly dissected by dendritic drainages.  Running through the middle of the study area is the Green River, a large alluvial river running from its headwaters in the Wind River Mountains of Wyoming to its confluence with the Colorado River farther south of the study site.  Compared to the Hanksville site, this area has higher drainage definition.  This is interpreted to be one reason why the slope-area relationship looks the way it does, following the predicted trends in slope relative to drainage area.

Remember, the predicted curve is based on the assumption of topographic steady-state.  Deviation from the predicted curve should reflect a landscape's non-steady-state condition.  Looking at all three plots, one could easily make the interpretation that non of these landscapes are in a topographic steady-state.  Montgomery's study of the Olympic Mountains in Washington (2001) yielded a slope-area plot more indicative of a landscape that is in steady-state (Fig 15).


Fig 15.    Slope-area plot from Montgomery (2001) for Olympic Mountain, WA.  Data show a pattern closely resembling the predicted curve, indicating a topographic steady-state.

If this method is a valid test of a landscape's steady-state condition, then it is reasonably clear that the Colorado Plateau should not be regarded as a landscape in a topographic steady-state at the present.  The three study sites chosen for this preliminary analysis all show slope-area relationships which do not follow the predicted curve.  Few would argue that at present time rates of uplift and erosion are equal, reflecting a non-steady-state condition.  These results seem to verify this using farely simple GIS methods.

Concerning the validity of the slope-area method itself, there are compelling questions that need to be answered.  Just how much variation is permissible? How much can a landscape's slope-area plot deviate from the predicted curve and still be considered steady-state?  This is difficult to answer because even the landscapes that show slope-area relationships closely resembling that which is predicted, are not interpreted by all workers as being in a topographic steady-state (Montgomery, 2001).  A more loose interpretation of the plots generated from the landscapes in this study might actually lead some to suggest that slope-area relationships do not provide a good test.  Each study site does follow the general trend expected, there is just a lot of scatter in the high drainage areas ranges.  Due to the fact that erosion and rock uplift rates are in no way close to the same, one might expect the relationships to be even more unlike the predicted.

In summary, this study suggests that general slope-area relationships exist regardless of the balance between rock uplift rates and erosion.  However, one signal in these relationships may be the degree of variation and magnitude of deviation from the predicted.  Large scatter in slope values near the high drainage area ranges may be an indication of non-steady-state topography.

References

Bull, W.B., (2002), "Steady-State landscapes--a convenient myth," Geological Society of America Abstract With Programs, Denver National meeting, v. 34, No. 6., 164-1.

Montgomery, D.M., (2001), “Slope Distributions, Threshold Hillslopes, and Steady-State Topography,” American Journal of Science, 301: 432-454.

Pazzaglia, F.J., and Brandon, M.T., (2001), "A fluvial record of long-term steady-state uplift and erosion across the Cascadia forearc high, western Washington State," American Journal of Science, 301: 385-431.

Pederson, J.L., Mackley, R.D., Eddleman, J.L., (2002), "Colorado Plateau uplift and erosion evaluated using GIS", GSA Today, v. 12, no. 8, p. 4-10.

Spencer, J.E., (1996), "Uplift of the Colorado Plateau due to lithospheric attenuation during Laramide low-angle subduction: Journal of Geophysical
Research, v. 101, p. 13,595-13,609.

Tarboton, D. G., (1997), "A New Method for the Determination of Flow Directions and Contributing Areas in Grid Digital Elevation Models," Water Resources Research, 33(2): 309-319.

Tarboton, D. G., R. L. Bras and I. Rodriguez-Iturbe, (1991), "On the Extraction of Channel Networks from Digital Elevation Data," Hydrologic Processes, 5(1): 81-100.

Whipple, K.X. (2001), "Fluvial landscape response time: How plausible is steady-state denudation?," American Journal of Science, 301: 313-325.

Whipple, K.X., and Tucker, G.E., (1999), "Dynamics of the stream-power river incision model: Implications for height limits of mountain ranges, landscape response timescales, and research needs," Journal of Geophysical Research, 104: 17661-17674.
 

Appendix

Stream Power Law
VB Code
    Tabulate
    Two To One
    Log Bin Averaging

Stream Power Law

    1)  Erosion described by:
                       ? = KAmSn

    2)  Assume Uplift = Erosion:
                 ? = U

    3)  Set 1) and 2) equal:

          S = (U/K)(1/n)A(m/n)         “Slope-Area Relationship”

Where:
? = erosion rate
U = rock uplift rate
K = coefficient of erosion
A = drainage area
m = area exponent
S = slope
n = slope exponent


It is expected that for hillslope processes m will be near 0.  For stream channel processes, m will be greater than 1.  From this, a predicted curve can be generated.
 
 

VB Code

The raw code can be copied and pasted into the editor.  The Toolset consists of four forms and two modules.  If you copy and paste the code, you must also create forms and modules with the same exact names in order for the program to work correctly.


Fig ??.    Project explorer showing the forms and modules comprising the toolset.
 

Tabulate Grid Cell Values Code (Located on Module1)
'start of code'
Sub convert()       'This is the subroutine that will extract the GRID values from the SafeArray _
                     and ouput a text file with only one column

' Dimensioning variables
    Dim Foldername As String
    Dim pGridname As String, dGridname As String
    Dim I As Long, j As Long, k As Long
    Dim pwidth As Variant, pheight As Variant
    Dim pFolder As String
    Dim pFile As String

' Specifying inputs.  These will come from user input on the frm.Covert form
     Foldername = frmConvert.txtFolder.Value   'folder containing GRID
     pFile = frmConvert.txtFile.Value          'name of GRID

    Dim tpixb As IPixelBlock, xll1 As Double, yll1 As Double, ncol1 As Long, nrow1 As Long
    Dim csize1 As Double, ndv1 As Double
    Set tpixb = GridToPixblock(Foldername, pFile, xll1, yll1, ncol1, nrow1, csize1, ndv1)
    'this calls up the function, GridToPixblock. This function does the work in reading the GRID values _
     and making a SafeArray

    pPixels = tpixb.SafeArray(0)

    'info about grid such as number of rows, columns and total cells
    pwidth = tpixb.Width
    pheight = tpixb.Height
    Dim intcount As Single
    intcount = pwidth * pheight 'total number of cells

    'This will print the values to a sequential text file
    Dim tt As Double
    Dim intctr As Single, intctr2 As Single 'column and row
    Dim pfactor As Double 'user specified scaling factor to be applied inorder to convert units or decimal _
                           places to the grid value

    Dim ptextout As String 'note to remind user that the path needs to ACTUALLY exist or there will be an error
    ptextout = InputBox("Type the Path and Name of the Output Text File." & _
    "MAKE SURE THE DIRECTORY ACTUALLY EXISTS!! OR YOU WILL GET AN ERROR MESSAGE!!", "Output Text File", _
    frmConvert.txtFolder & "\Textout.txt")

    Open ptextout For Output As #1 'the sequential text file that will be output.  Path and name are specified _
                                    in the input box

    Dim ii As Long, jj As Integer
    ii = 0
    For intctr = 1 To pwidth - 1 Step 1 'loop through all columns
    For intctr2 = 1 To pheight - 1 Step 1 'loop through all rows
    ii = ii + 1

    tt = pPixels(intctr, intctr2) 'here, the tt variable will equal the actual value in the specified cell _
                                   with intctr and intctr2 representing the column and row respectively

    If tt <= -3.40282346638529E+30 Then 'this is so the nodata (usually really small negative numbers) will _
                                         not skew the data
        tt = 0
        Else
        tt = pPixels(intctr, intctr2)
    End If
    pfactor = frmConvert.txtFactor.Value 'the user specified scaling factor is brought in from the form

    Print #1, tt * pfactor 'this step prints the cell value from the SafeArray to the sequential output text file
    Next intctr2 'next row in loop
    Next intctr 'next column in loop

    Close #1
        MsgBox ("Thank you for running Rob's amazing GRID TO SINGLE COLUMN converter, Grid cell values have been " & _
        "written to c:\output.txt")

    frmConvert.Hide
    frmConvert.Show

End Sub

Public Function GridToPixblock(Foldername As String, pGridname As String, ByRef xll As Double, _
ByRef yll As Double, ByRef ncol As Long, ByRef nrow As Long, ByRef csize As Double, _
ByRef NoDataValue As Double) As IPixelBlock
 

' READ THE FLOW DIRECTION GRID
' Now work with the flow direction grid

'  Raster workspace factory object
   Dim pWSF As IWorkspaceFactory    '  This statement would generally be needed, but is not here _
                                       because we are reusing the same workspace factory name used above.
   Set pWSF = New RasterWorkspaceFactory

' Raster workspace object
    Dim pRWS As IRasterWorkspace
    Set pRWS = pWSF.OpenFromFile(Foldername, 0)

' Raster dataset object
    Dim pRsDS As IRasterDataset
    Set pRsDS = pRWS.OpenRasterDataset(pGridname)

' Raster object
   Dim pRs As IRaster
   Set pRs = pRsDS.CreateDefaultRaster

' Raster band collection object.  Rasters may contain multiple bands
   Dim pRsBC As IRasterBandCollection
   Set pRsBC = pRs

' Raster band object
    Dim pRsBand As IRasterBand
    Set pRsBand = pRsBC.Item(0)    ' The first band, i.e. item number 0 in the band collection

' Raster properties object
    Dim pRsProp As IRasterProps
    Set pRsProp = pRsBand

'  Get the size and extent of flow direction grid
    xll = pRsProp.Extent.XMin
    yll = pRsProp.Extent.YMin
    ncol = pRsProp.Width
    nrow = pRsProp.Height
    csize = pRsProp.MeanCellSize.x

' Raw Pixel objects.  These are used to access the raw data in grids
    Dim pRawPixels As IRawPixels
    Set pRawPixels = pRsBand

'  No data value
   NoDataValue = pRsProp.NoDataValue

' Set up double point object specifying the extent of the part of the grid to work with. _
In this case the entire grid.

    Dim pPnt As IPnt
    Set pPnt = New DblPnt
    pPnt.SetCoords pRsProp.Width, pRsProp.Height

' Pixel block objects to work with,within extent specified by pPnt (in this case the entire grid).
   Set GridToPixblock = pRawPixels.CreatePixelBlock(pPnt)
   ' Origin of coordinates to be read from raw pixels into pixel block
  Dim pOrigin As IPnt
    Set pOrigin = New DblPnt
    pOrigin.SetCoords 0, 0

' Read block of flow direction pixels into PixelBlock
    pRawPixels.read pOrigin, GridToPixblock
End Function

'end of code

Two To One, Combining Text File Code (Located on Module1)

'start of code

Sub TwoToOne()
' this is the subroutine that writes 1 text file containing two rows from the 2 sequential files created during _
the Tabulate step performed earlier

run:
    Dim intctr As Double, intctr2 As Double ' column and row
    Dim textout2 As Integer, textrand2 As Integer
    Dim intmsg As Integer
    Dim val As Double, val2 As Double
    Dim slopein As String, areain As String, report As String

    Open frmLoad.dbAreaOpen.FileName For Input As #1 'user-specified input file with single column of area values
    Open frmLoad.dbSlopeOpen.FileName For Input As #2 'user-specified input file with single column of slope values
    Open frmLoad.dbSave.FileName For Output As #3 'user-specified output file containing two rows of data, slope _
                                                   and area values
    Do While Not EOF(1) 'a loop that will continue until the end of the input text file is meet
    Input #1, val
    Input #2, val2
    Write #3, val; val2
    Loop 'next pair of area and slope values

Close #1 'close the text files
Close #2
Close #3

report = MsgBox("Congratulations, you are done. The file has been written to " & frmLoad.dbSave.FileName, _
vbApplicationModal, "Area-Slope Text File Created") 'report that things went successfully and where the output
                                                    'file was written to

frmLoad.Hide
frmMain.Hide
frmMain.Show

End Sub

'end of code

Log Binning and Averaging (Located on Module2)

'start of code
Sub logbinaverage()
    Dim area As Double, slope As Double

    Dim i0 As Double, I As Double, i1 As Double, i2 As Double, i3 As Double, i4 As Double, i5 As Double, i6 As Double, _
    i7 As Double, i8 As Double, i9 As Double, i10 As Double, i11 As Double, i12 As Double, i13 As Double, _
    i14 As Double, i15 As Double, i16 As Double, i17 As Double, i18 As Double, i19 As Double, i20 As Double

    Dim n0 As Double, n As Double, n1 As Double, n2 As Double, n3 As Double, n4 As Double, n5 As Double, _
    n6 As Double, n7 As Double, n8 As Double, n9 As Double, n10 As Double, n11 As Double, n12 As Double, _
    n13 As Double, n14 As Double, n15 As Double, n16 As Double, n17 As Double, n18 As Double, n19 As Double, _
    n20 As Double

    Dim sum0 As Double, sum As Double, sum1 As Double, sum2 As Double, sum3 As Double, sum4 As Double, _
    sum5 As Double, sum6 As Double, sum7 As Double, sum8 As Double, sum9 As Double, sum10 As Double, _
    sum11 As Double, sum12 As Double, sum13 As Double, sum14 As Double, sum15 As Double, sum16 As Double, _
    sum17 As Double, sum18 As Double, sum19 As Double, sum20 As Double

    Dim average0 As Double, average As Double, average1 As Double, average2 As Double, average3 As Double, _
    average4 As Double, average5 As Double, average6 As Double, average7 As Double, average8 As Double, _
    average9 As Double, average10 As Double, average11 As Double, average12 As Double, average13 As Double, _
    average14 As Double, average15 As Double, average16 As Double, average17 As Double, average18 As Double, _
    average19 As Double, average20 As Double

    Dim sd0 As Double, sd As Double, sd1 As Double, sd2 As Double, sd3 As Double, sd4 As Double, sd5 As Double, _
    sd6 As Double, sd7 As Double, sd8 As Double, sd9 As Double, sd10 As Double, sd11 As Double, sd12 As Double, _
    sd13 As Double, sd14 As Double, sd15 As Double, sd16 As Double, sd17 As Double, sd18 As Double, asd19 As Double, _
    sd20 As Double

    'On Error GoTo perror

    Open frmLogBinAverage.dbTextIn.FileName For Input As #1
    'Open "c:\cottonwood\both_d8.txt" For Input As #1
    Open frmLogBinAverage.dbTextOut.FileName For Output As #2
    'Open "c:\cottonwood\both_d8_logbinavg.txt" For Output As #2
    Dim multiplier As Double
    Dim order As Long

    order = InputBox("What number in the sequence will this output file be?", "Output Order Number", "1,2,3 or 4")
    If order = 1 Then
        multiplier = 100
    End If
    If order = 2 Then
        multiplier = 10000
    End If
    If order = 3 Then
        multiplier = 1000000
    End If
    If order = 4 Then
        multiplier = 100000000
    End If
 
 

    i0 = 0
    I = 0
    i1 = 0
    i2 = 0
    i3 = 0
    i4 = 0
    i5 = 0
    i6 = 0
    i7 = 0
    i8 = 0
    i9 = 0
    i10 = 0
    i11 = 0
    i12 = 0
    i13 = 0
    i14 = 0
    i15 = 0
    i16 = 0
    i17 = 0
    i18 = 0
    i19 = 0
    i20 = 0

    sum0 = 0
    sum = 0
    sum1 = 0
    sum2 = 0
    sum3 = 0
    sum4 = 0
    sum5 = 0
    sum6 = 0
    sum7 = 0
    sum8 = 0
    sum9 = 0
    sum10 = 0
    sum11 = 0
    sum12 = 0
    sum13 = 0
    sum14 = 0
    sum15 = 0
    sum16 = 0
    sum17 = 0
    sum18 = 0
    sum19 = 0
    sum20 = 0

    Dim lowercase0 As Double, lowercase As Double, lowercase1 As Double, lowercase2 As Double, lowercase3 As Double, _
    lowercase4 As Double, lowercase5 As Double, lowercase6 As Double, lowercase7 As Double, lowercase8 As Double, _
    lowercase9 As Double, lowercase10 As Double, lowercase11 As Double, lowercase12 As Double, lowercase13 As Double, _
    lowercase41 As Double, lowercase15 As Double, lowercase16 As Double, lowercase17 As Double, lowercase18 As Double, _
    lowercase19 As Double, lowercase20 As Double

    Dim uppercase0 As Double, uppercase As Double, uppercase1 As Double, uppercase2 As Double, uppercase3 As Double, _
    uppercase4 As Double, uppercase5 As Double, uppercase6 As Double, uppercase7 As Double, uppercase8 As Double, _
    uppercase9 As Double, uppercase10 As Double, uppercase11 As Double, uppercase12 As Double, uppercase13 As Double, _
    uppercase14 As Double, uppercase15 As Double, uppercase16 As Double, uppercase17 As Double, uppercase18 As Double, _
    uppercase19 As Double, uppercase20 As Double

    lowercase0 = 0
    lowercase = 1 * multiplier
    lowercase1 = 2 * multiplier
    lowercase2 = 3 * multiplier
    lowercase3 = 4 * multiplier
    lowercase4 = 5 * multiplier
    lowercase5 = 6 * multiplier
    lowercase6 = 7 * multiplier
    lowercase7 = 8 * multiplier
    lowercase8 = 9 * multiplier
    lowercase9 = 10 * multiplier
    lowercase10 = 20 * multiplier
    lowercase11 = 30 * multiplier
    lowercase12 = 40 * multiplier
    lowercase13 = 50 * multiplier
    lowercase14 = 60 * multiplier
    lowercase15 = 70 * multiplier
    lowercase16 = 80 * multiplier
    lowercase17 = 90 * multiplier
    lowercase18 = 100 * multiplier
    lowercase19 = 200 * multiplier
    lowercase20 = 300 * multiplier

    uppercase0 = 1 * multiplier
    uppercase = 2 * multiplier
    uppercase1 = 3 * multiplier
    uppercase2 = 4 * multiplier
    uppercase3 = 5 * multiplier
    uppercase4 = 6 * multiplier
    uppercase5 = 7 * multiplier
    uppercase6 = 8 * multiplier
    uppercase7 = 9 * multiplier
    uppercase8 = 10 * multiplier
    uppercase9 = 20 * multiplier
    uppercase10 = 30 * multiplier
    uppercase11 = 40 * multiplier
    uppercase12 = 50 * multiplier
    uppercase13 = 60 * multiplier
    uppercase14 = 70 * multiplier
    uppercase15 = 80 * multiplier
    uppercase16 = 90 * multiplier
    uppercase17 = 100 * multiplier
    uppercase18 = 200 * multiplier
    uppercase19 = 300 * multiplier
    uppercase20 = 400 * multiplier

    Do While Not EOF(1)
             Input #1, area, slope   ' Read data into two variables.
                If area > lowercase0 Then
                    If area <= uppercase0 Then
                        sum0 = sum0 + slope
                        i0 = i0 + 1
                        n0 = i0
                        average0 = sum0 / n0
                        sd0 = Sqr(((slope - average0) ^ 2) / n0)
                    End If
                End If
                If area > lowercase Then
                    If area <= uppercase Then
                        sum = sum + slope
                        I = I + 1
                        n = I
                        average = sum / n
                        sd = Sqr(((slope - average) ^ 2) / n)
                    End If
                End If

                If area > lowercase1 Then
                    If area <= uppercase1 Then
                        sum1 = sum1 + slope
                        i1 = i1 + 1
                        n1 = i1
                        average1 = sum1 / n1
                        sd1 = Sqr(((slope - average1) ^ 2) / n1)
                    End If
                End If

                If area > lowercase2 Then
                    If area <= uppercase2 Then
                        sum2 = sum2 + slope
                        i2 = i2 + 1
                        n2 = i2
                        average2 = sum2 / n2
                        sd2 = Sqr(((slope - average2) ^ 2) / n2)
                    End If
                End If

                If area > lowercase3 Then
                    If area <= uppercase3 Then
                        sum3 = sum3 + slope
                        i3 = i3 + 1
                        n3 = i3
                        average3 = sum3 / n3
                        sd3 = Sqr(((slope - average3) ^ 2) / n3)
                    End If
                End If

                If area > lowercase4 Then
                    If area <= uppercase4 Then
                        sum4 = sum4 + slope
                        i4 = i4 + 1
                        n4 = i4
                        average4 = sum4 / n4
                        sd4 = Sqr(((slope - average4) ^ 2) / n4)
                    End If
                End If

                If area > lowercase5 Then
                    If area <= uppercase5 Then
                        sum5 = sum5 + slope
                        i5 = i5 + 1
                        n5 = i5
                        average5 = sum5 / n5
                        sd5 = Sqr(((slope - average5) ^ 2) / n5)
                    End If
                End If

                If area > lowercase6 Then
                    If area <= uppercase6 Then
                        sum6 = sum6 + slope
                        i6 = i6 + 1
                        n6 = i6
                        average6 = sum6 / n6
                        sd6 = Sqr(((slope - average6) ^ 2) / n6)
                    End If
                End If

                If area > lowercase7 Then
                    If area <= uppercase7 Then
                        sum7 = sum7 + slope
                        i7 = i7 + 1
                        n7 = i7
                        average7 = sum7 / n7
                        sd7 = Sqr(((slope - average7) ^ 2) / n7)
                    End If
                End If

                If area > lowercase8 Then
                    If area <= uppercase8 Then
                        sum8 = sum8 + slope
                        i8 = i8 + 1
                        n8 = i8
                        average8 = sum8 / n8
                        sd8 = Sqr(((slope - average8) ^ 2) / n8)
                    End If
                End If

                If area > lowercase9 Then
                    If area <= uppercase9 Then
                        sum9 = sum9 + slope
                        i9 = i9 + 1
                        n9 = i9
                        average9 = sum9 / n9
                        sd9 = Sqr(((slope - average9) ^ 2) / n9)
                    End If
                End If
                If area > lowercase10 Then
                    If area <= uppercase10 Then
                        sum10 = sum10 + slope
                        i10 = i10 + 1
                        n10 = i10
                        average10 = sum10 / n10
                        sd10 = Sqr(((slope - average10) ^ 2) / n10)
                    End If
                End If
                If area > lowercase11 Then
                    If area <= uppercase11 Then
                        sum11 = sum11 + slope
                        i11 = i11 + 1
                        n11 = i11
                        average11 = sum11 / n11
                        sd11 = Sqr(((slope - average11) ^ 2) / n11)
                    End If
                End If

                If area > lowercase12 Then
                    If area <= uppercase12 Then
                        sum12 = sum12 + slope
                        i12 = i12 + 1
                        n12 = i12
                        average12 = sum12 / n12
                        sd12 = Sqr(((slope - average12) ^ 2) / n12)
                    End If
                End If

                If area > lowercase13 Then
                    If area <= uppercase13 Then
                        sum13 = sum13 + slope
                        i13 = i13 + 1
                        n13 = i13
                        average13 = sum13 / n13
                        sd13 = Sqr(((slope - average13) ^ 2) / n13)
                    End If
                End If

                If area > lowercase14 Then
                    If area <= uppercase14 Then
                        sum14 = sum14 + slope
                        i14 = i14 + 1
                        n14 = i14
                        average14 = sum14 / n14
                        sd14 = Sqr(((slope - average14) ^ 2) / n14)
                    End If
                End If

                If area > lowercase15 Then
                    If area <= uppercase15 Then
                        sum15 = sum15 + slope
                        i15 = i15 + 1
                        n15 = i15
                        average15 = sum15 / n15
                        sd15 = Sqr(((slope - average15) ^ 2) / n15)
                    End If
                End If

                If area > lowercase16 Then
                    If area <= uppercase16 Then
                        sum16 = sum16 + slope
                        i16 = i16 + 1
                        n16 = i16
                        average16 = sum16 / n16
                        sd16 = Sqr(((slope - average16) ^ 2) / n16)
                    End If
                End If

                If area > lowercase17 Then
                    If area <= uppercase17 Then
                        sum17 = sum17 + slope
                        i17 = i17 + 1
                        n17 = i17
                        average17 = sum17 / n17
                        sd17 = Sqr(((slope - average17) ^ 2) / n17)
                    End If
                End If

                If area > lowercase18 Then
                    If area <= uppercase18 Then
                        sum18 = sum18 + slope
                        i18 = i18 + 1
                        n18 = i18
                        average18 = sum18 / n18
                        sd18 = Sqr(((slope - average18) ^ 2) / n18)
                    End If
                End If

                If area > lowercase19 Then
                    If area <= uppercase19 Then
                        sum19 = sum19 + slope
                        i19 = i19 + 1
                        n19 = i19
                        average19 = sum19 / n19
                        sd19 = Sqr(((slope - average19) ^ 2) / n19)
                    End If
                End If
                If area > lowercase20 Then
                    If area <= uppercase20 Then
                        sum20 = sum20 + slope
                        i20 = i20 + 1
                        n20 = i20
                        average20 = sum20 / n20
                        sd20 = Sqr(((slope - average20) ^ 2) / n20)
                    End If
                End If
 
 

    Loop
    Print #2, lowercase0 & " - " & uppercase0; average0; n0; sd0
    Print #2, lowercase & " - " & uppercase; average; n; sd
    Print #2, lowercase1 & " - " & uppercase1; average1; n1; sd1
    Print #2, lowercase2 & " - " & uppercase2; average2; n2; sd2
    Print #2, lowercase3 & " - " & uppercase3; average3; n3; sd3
    Print #2, lowercase4 & " - " & uppercase4; average4; n4; sd4
    Print #2, lowercase5 & " - " & uppercase5; average5; n5; sd5
    Print #2, lowercase6 & " - " & uppercase6; average6; n6; sd6
    Print #2, lowercase7 & " - " & uppercase7; average7; n7; sd7
    Print #2, lowercase8 & " - " & uppercase8; average8; n8; sd8
    Print #2, lowercase9 & " - " & uppercase9; average9; n9; sd9
    Print #2, lowercase10 & " - " & uppercase10; average10; n10; sd10
    Print #2, lowercase11 & " - " & uppercase11; average11; n11; sd11
    Print #2, lowercase12 & " - " & uppercase12; average12; n12; sd12
    Print #2, lowercase13 & " - " & uppercase13; average13; n13; sd13
    Print #2, lowercase14 & " - " & uppercase14; average14; n14; sd14
    Print #2, lowercase15 & " - " & uppercase15; average15; n15; sd15
    Print #2, lowercase16 & " - " & uppercase16; average16; n16; sd16
    Print #2, lowercase17 & " - " & uppercase17; average17; n17; sd17
    Print #2, lowercase18 & " - " & uppercase18; average18; n18; sd18
    Print #2, lowercase19 & " - " & uppercase19; average19; n19; sd19
    Print #2, lowercase20 & " - " & uppercase20; average20; n20; sd20

    Close #1, #2
frmLogBinAverage.Hide
frmLogBinAverage.Show

End Sub
'end of code