StPro UserGuidees Final PDF
StPro UserGuidees Final PDF
StPro UserGuidees Final PDF
1
Ch. 1 – DEM Preparation Guide
2. Or, you can “Import” an existing coordinate system from another GIS
file that you might already have that is in the projection that you want
the new data to conform to.
iv. For “Resampling,” be sure to select ‘bilinear’ for the projection calculation (this
prevents linear artifacts from being introduced into your data)
v. It is best to specify the output cell size to the native posting for the DEM
(otherwise you get something like 9.78m, and parts of the DEM may get cut-off
in some cases)
1. Depending on what you downloaded:
a. If using 1/3 arc second data, specify that the cells are 10m
b. If using 1 arc second data, specify that the cells are 30m
2. This will not affect the quality of the data…It WILL prevent the
northern areas from being clipped off during reprojections.
6. Remove Ocean or negative values if you wish to mask them out of your DEM
A. Use: Spatial Analyst Tools / Math / Logical / Greater Than
i. Specify the input DEM
ii. Specify the value you want your DEM to be greater than (0m ?)
iii. Specify the name and location for the output raster – this grid will have a value
of “1” everywhere elevations are greater than you specified (0m) and “0”
elsewhere.
iv. Use: Spatial Analyst -> Raster Calculator to divide your original DEM by this
mask grid to create a DEM only composed of regions where elevations are
greater than what you specified (0m). Cell values will be “NoData” elsewhere.
B. If you have bathymetric data, you may want to take your data and add a large number to
all your elevations (like 10,000). This will allow all your elevations to be positive
without affecting the accuracy of the data. To do this use the raster calculator under
Spatial Analyst to add 10,000 to each cell in your DEM.
Steps 7 – 10 below are time consuming. We have prepared a user-installable “Profiler Toolbox” that
can be added to ArcGIS (must be done in each new ArcMap project) and will automate these steps
while you are away from your computer.
A. There are three files included, 2 Python scripts (*.py) and the toolbox. In ArcMap (or
any Arc app for that matter) open up ArcToolbox (little red box), then right-click within
this window, choose "add toolbox" and search for the add-in toolbox "Profiler Tools".
B. You now have a little red toolbox called "Profiler Tools". Expand it, and right click the
function "Profiler DEM Preparation" in the new toolbox "Profiler Tools" and click
Properties. Go to the "Source" tab and point it to the file "ProfilePrep9_1.py" or
"ProfilePrep9_2.py", depending on which version of Arc is being run (9.1 vs 9.2).
C. Once that is done, you can use the “Profiler DEM Preparation” function like any other
within ArcToolbox. Double click it and a dialog box opens where you can enter a DEM
and spit out the filled DEM, flow direction raster, acc raster, and ascii versions of the
original DEM and acc grid. This can take a while, depending on DEM size, computer
speed, and how rough the DEM is (how many pits need to be filled). When this process
is complete, you are now ready to skip to step 11 where you use the arcdemtxt2matlab.m
function to convert the ascii rasters to compact matlab binary files.
2
Ch. 1 – DEM Preparation Guide
10. Export your Integer Accumulation and your original unfilled DEM to ASCII files
A. These .txt outputs will be used by MATLAB to extract channel profiles.
B. Use: Conversion Tools / From Raster / Raster to ASCII
i. Specify the location of the original, projected, unfilled DEM or accum grids.
ii. Specify the output names for the .txt files
1. NOTE! You must follow the following naming convention!
a. DEM file: file_namedem.txt
b. Accum file: file_nameacc.txt
2. e.g. if you are working on the snake river, you might create:
a. snakedem.txt and snakeacc.txt
b. do not worry that you do not see a projection file (*.prj) –
projection information is all in the headers of the ascii files
(*.txt) exported from ArcGis.
11. Use MATLAB to convert the exported .txt files into .mat data files.
A. Open MATLAB and change the working directory to be where you have the .txt files
stored. Place a copy of the code “arcdemtxt2matlab.m” in the same directory.
B. Convert .txt files to MATLAB .mat data files
i. Note: File naming convention must be followed. (See 10.b.ii above)
ii. In the Command Window, type:
1. arcdemtxt2matlab('matlab_directory',‘file_name’) [note: single quotes
are required for matlab to recognize characters];
a. ‘matlab_directory’ must be the full path name to the directory
where your *dem.txt and *acc.txt files are stored (e.g.,
‘C:\user_data\my_project\matlab’), and is where the matlab
binary files will be written. See Chapter 3, item 1 for a
recommended directory structure to organize your files.
b. This will start a program that changes your .txt files into the
more efficient .mat file format. The .mat files are saved in the
current directory as well as a projection-aware metadata file.
c. The filenames created by the code arcdemtxt2matlab.m will be
named ‘file_nameaccm.mat’ and ‘file_namedemm.mat’
3
Ch. 1 – DEM Preparation Guide
If you are familiar with ArcGIS Model Builder, this can be another useful way to automate the steps
above, rather than using the user installable add-in toolbox provided. In model-space, the flow of
steps would look something like this.
Create
Namedem.prj
file (missing)
Generally clipping watersheds is not needed for stream profile analysis. However, if your
*dem.txt and *acc.txt files are much greater than 100Mb (source grids bigger than about 5000 x
5000 pixels), you will run into memory limits of Matlab on a WinXP (32 bit) PC. One solution is
to run the 64bit version of Matlab on Linux, Win 64bit or Vista on a machine with > 4Gb Ram.
Alternatively, you can subdivide the dem into smaller parts for analysis in Matlab. An easy way is
to set your ArcMap display to show just the area you want to send to matlab and when running
Export in Step 10, under Environments > General Settings > Extent choose “Same as Display”.
You can keep the full dem in Arc, and just process one overlapping piece at a time in Matlab.
Another popular alternative is to clip out individual watersheds for analysis. Unfortunately
ArcMap is a bit cumbersome at defining watersheds for clipping. A convenient solution is offered
by an add-in toolbox written by Peter Isaacson called the “Hydrology Module” (see below for
installation steps).
4
Ch. 1 – DEM Preparation Guide
A. In the “Hydrology Module”, choose “Interactive Properties”. The flow direction grid and
flow accumulation grids were created above. Click “OK”.
B. Click the “Watershed” button on the hydrology module, and then click on the point
closest to the mouth of the river (choose by eye, easier if you are zoomed in, best if you
are looking at the flow accumulation grid, not the dem). Once done, you will see that
your watershed is masked out.
C. Convert the watershed raster to a polygon to use for mask. In the “Conversion Tools”
tool box, chose “From Raster” and “Raster to Polygon”. Input raster is the watershed
raster, output polygon is the name of your new polygon. MAKE SURE YOU UNCLICK
“Simply polygons”. If you don’t do this, parts of the outer edge of your watershed will
be cut-out.
D. You want to export data from your watershed only. In the “Spatial Analyst” Tool box,
“Extraction” box, double click on “Extract by Mask”. The “Input Raster” is your
UNFILLED DEM, the “Input raster or feature Mask data” is the watershed polygon that
you just created, and the “Ouput raster” is your soon-to-be-created DEM of this
watershed only. Note that if you use the raster watershed without making it into a
polygon, you will create a raster that only has values in the watershed, but it will have no
data values covering the rest of the area – these “nodata” points still count against total
memory. The point is to reduce the total number of points in the raster whether these are
“nodata” or not.
This is the link where you can download the hydrology extension.
http://arcobjectsonline.esri.com/ArcObjectsOnline/Samples/Spatial
%20Analyst/Hydrology%20Modeling/HydrologyModeling.htm
To install it, you need to have administrator permissions on the local machine (not Domain).
Follow the instructions from Chapter 2 on installing the Profiler Toolbar dll (process is the same).
Then in ArcMap, you should be able to add this extension (tools menu > customize > toolbars>
add from file > click the dll). Then you should be able to use it like any other toolbar. Installing it
once on your machine is sufficient, unless you re-install ArcGIS.
5
Ch. 2 – Installing the Toolbar
B. Click on Add from File (the middle button on the bottom of the form). This
allows you to add a dll that has been registered with Windows and with
ArcGIS. The dll has been written to interact directly with ArcGIS. Navigate to
the folder where you saved profiler.dll, highlight profiler.dll then click on
open
C. Once you do, you should see a form something like this:
7
Ch. 2 – Installing the Toolbar
D. These are the subroutines, forms, and toolbar that make up the new profiler
tool. Click on the Profiler Toolbar in the list of toolbars. You should see the
toolbar:
3. The best practice for installing a new, improved version of the profiler toolbar when
released is to completely remove any memory of the old version before installing the new
one as listed above. The procedure is:
8
Ch. 3 – Extracting and analyzing Profile Data
Chapter 3 - Using the Profiler Toolbar and Matlab codes for extracting
and analyzing stream profile data
1. Set up a convenient directory structure for your project.
Our stream profile analysis tools generate a lot of files (most of them quite small). Keeping
everything well organized from the start is HIGHLY recommended. The following directory
structure works well.
A. Store all the profiler matlab codes in one place, separate from any particular analysis
project. Set this as the Working Directory in Matlab, or add this directory to Matlab’s
PATH (C:\Program Files\ArcGIS_Stream_Profiler\Mfiles might be a good choice).
B. Place your *dem.txt and *acc.txt ascii files exported from ArcGIS into the directory you
want all matlab data files stored (model: C:\user_data\my_project\matlab); this will be
your “matlab_directory”.
C. Create a directory where you want all files created by the Profiler Toolbar stored (model:
C:\user_data\my_project\arcmap); this will be your “arcmap_directory”. This directory
will be empty to start with. You CAN use a single directory for both arcmap and matlab
files, however as numbers of files grows you will wish you kept them separate.
A. Make sure that the unfilled DEM grid is loaded into and visible in ArcMap.
i. It is not really necessary to have any other layers loaded or visible
a. once you have run the code a few times and been successful at
extracting profiles, you may want to delete the intermediate files that
you created (fill, direction, accum, etc) to save disk space.
ii. It can be helpful to add other layers or manipulate the DEM and Accumulation
so that they best help you visualize the topography.
a. To see your stream network, it’s sometimes good to classify the
accumulation into two classes. I make all the low drainage area points
(0-1000 pixels) transparent and then make all the other large drainage
area pixels (>1000 pixels) some color (blue?).
b. To find your channel heads, it may be useful to create contour lines or a
shaded relief map for your DEM. Go to Spatial Analyst>Surface
Analysis>Contour (or Hillshade) and select a reasonable contour
interval (or illumination source) for your DEM.
B. Define Parameters in the info window in the profiler tool (shown on page 11). Click on
the red ‘i’. Set the working directory FIRST.
i. The “Working Folder” should be set to your “arcmap_directory”;
C:\user_data\my_project\arcmap or similar and is where the Profiler Toolbar
will look to both write and read. It MUST be the same directory specified as
“arcmap_directory” when you run the Matlab codes. You can type or
copy/paste the full pathname into the middle box (C:\ by default) instead of
browsing, which can be slow.
ii. Select your DEM from the dropdown list
iii. Choose a project name. This will save your settings in a file
“projectname_parameters.txt” so you retain a record and can easily reload these
settings with the “Import Saved Parameters” button at the top of the form.
iv. Theta Ref should be between 0.4 and 0.6, depending on your field site. 0.45 is a
good start (default)
v. The spike remover takes out any data spikes in your profile. Recommended for
DEMs that had lots of pits to fill (e.g., SRTM DEMs)
vi. The step remover removes artifacts from USGS 10m DEMs, and allows no
additional smoothing. This option is NOT implemented for Batch processing
(using profile51_batch.m and the “Auto KS Import” button on the Profiler
Toolbar)
9
Ch. 3 – Extracting and analyzing Profile Data
vii. Smoothing window is the length of a moving average window over which
Matlab will smooth raw profile data (in meters). Uncheck the Smooth Profile?
box to do no smoothing. For rougher and lower resolution data, longer
smoothing windows can be helpful. 250m is great for USGS DEMs, 1000m,
possibly more useful on very rough data (some SRTM 3 arc second data).
viii. Contour sampling interval is the vertical distance Matlab will use to calculate
raw slopes (NOTE: 12.192m is equivalent to the 40ft contour interval most
DEMs were created from). This form of smoothing is always done, to eliminate
smoothing, set = 1m. Coarse, rough data, requires larger contour intervals (20m
is recommended for SRTM 3 arc second data). Choice depends on the detail
you need to capture and the quality of your data – what is real and what is noise?
ix. Auto k_sn Window is the width of a moving window that Matlab uses to
calculate normalized steepness indices along the entire length of a profile. This
can provide a handy guide to profile analysis, can help determine if you have
chosen a reasonable Theta_ref for your area, and is very similar to how the
Batch processing mode (using profile51_batch.m and the “Auto KS Import”
button on the Profiler Toolbar) works to automate determination of normalized
steepness indices for an entire catchment.
x. Search distance is the distance Matlab will search downstream from your
selected channel head (in pixels) to make sure it’s actually in the channel. The
routine used to locate actual stream heads (and to eliminate the need to very
carefully pick points selected in step 2 below) is as follows: (1) from your
selected point the channel extractor runs downhill a number of pixels set by
“Search Distance”; (2) the channel extractor then turns around and follows the
channel all the way to the divide; (3) it then turns around again, moving
downstream and begins data extraction (distance, elevation, drainage area) when
it reaches the “Minimum Accumulation” (again in pixels) specified below. This
way by picking anywhere near the channel of interest you can always extract
exactly the same channel, and you can always start as near the divide as you like
without needing to zoom way in when choosing your channel head position.
xi. Minimum Accumulation helps Matlab define where the actual channel head is:
it is the number of pixels that contribute to the uppermost pixel in your channel
(see “j” above).
xii. Click the “Save parameters to file” tab at the bottom
xiii. Check that you created a new file called “run_parameters.txt” in the directory
that you specified. “run_parameters.txt” is the “active” file that both Matlab
codes and the Profiler Toolbar look to for information when running. This is
overwritten each time you click “Save parameters to file”. Your settings are
permanently saved in a copy called “projectname_parameters.txt”.
10
Ch. 3 – Extracting and analyzing Profile Data
11
Ch. 3 – Extracting and analyzing Profile Data
A. The code will start the extraction at the headwaters of the stream you click in and
continue to extract channel data downstream until reaching the edge of the DEM.
i. Click on the toolbar button that says “(red-dot) to ML.” This will start up cross-
hairs that can be used to locate which stream you would like to extract. Cross-
hairs stay active until you select another ArcMap tool or another button on the
Profiler Toolbar.
a. Use the cross-hairs to click near a channel head on your DEM.
b. IF you clicked a point by accident at any point you must not “x” out of
the box: just use a dummy name and choose “submit name and close
file”. Picking a new location will over-write the bad one.
c. Give the stream a name (your choice, I recommend numerical)
d. Click “Submit Name” if you want to do a cluster of streams, or click
“Submit Name and close file” to just do a single stream. You can
always do more later.
e. If you hit “submit name” previously, you can repeat for each channel
you want to analyze as a cluster. When done, click on “Submit name
and close file”
ii. You can now see in the directory that you specified as the “arcmap_directory” in
the parameter window that there is a file called “location_ij.txt”. [To check that
everything is OK, you can open this file in a text editor and make sure the file
contains as many channels as you selected]. Data format is [row column easting
northing streamname].
A. Copy the following call line into the Matlab “Command Window.” It will be the
template that you will use when you are ready to run the profile extraction code.
i. profile51(‘file_name’, ‘arcmap_directory’, ‘matlab_directory’, ‘n’);
ii. Note that all fields in single-quotes must be written that way or the code will not
work (Matlab is looking for strings in each of these spots)
a. ‘file_name’ : The prefix in front of your *demm and *accm files
b. ‘arcmap_directory’ : Directory specified Profiler info-box in Arcmap
c. ‘matlab_directory’ : Directory where your *demm.mat, *accm.mat,
and *meta.mat files reside.
d. ‘n’ : This tells Matlab that you have not yet extracted the profile data
from each stream so it needs to create it. ‘y’ tells matlab to process
previously created ‘streamname’_chandata.mat files (either to re-do an
analysis or to run regressions on channels extracted in batch mode [see
7. Advanced options. Note that to change analysis options (smoothing,
etc) you need to edit “run_parameters.txt” either in a text editor or by
using the “i” define parameters dialog in ArcMap (see 2.2 above).
e. Best to include the semicolon at the end of matlab commands as this
suppresses matlab from writing the results to the screen (which usually
takes 100x longer than the calculation itself).
iii. Press Enter (Note: make sure you’ve got a “location_ij.txt” file before you type
enter or Matlab won’t know where to start!)
A. Once you hit Enter in Step 2, the MATLAB codes will create two plots (shown below)
and step you through a series of analyses.
12
Ch. 3 – Extracting and analyzing Profile Data
Figure 2 Explained: In the top plot, the observed and predicted channel profiles for each analyzed reach
are shown. Raw elevations are in green, smoothed in pink. The dark blue lines are the profiles predicted by
the regressed channel concavity, θ. The cyan lines are for the specified reference concavity, θref. The plus
marks along the profile indicate the locations of user-specified knickpoint positions. In the lower plot the
same blue and cyan colors show the regressed and reference concavities, respectively. Red squares are log-
bin averages of the S-A data and open circles show the locations of the knickpoints as plotted on the long
profile. This is the plot that can be pulled up using hyperlink tool on single-channel shapefiles in arcmap.
13
Ch. 3 – Extracting and analyzing Profile Data
Figure 3 Explained: The top plot is the profile data with elevation plotted against c, the integral
of drainage area to that point on the profile (see 2007 GSA Short Course lecture for notes on the
“Integral Method” used to determine the regression fits with specified reference concavity (plotted
in dark blue). Middle plot is local slope plotted against distance from mouth. Regression lines as
in Figure 2. On the upper two plots, open circles are user-selected knickpoint locations. The
lower plot shows the automated calculation of normalized channel steepness (ksn) over user
specified moving window width (auto ksn window). These can be a helpful guide to choosing
regression limits on the log gradient – distance plot above (option c).
14
Ch. 3 – Extracting and analyzing Profile Data
15
Ch. 3 – Extracting and analyzing Profile Data
tributaries relative to the mainstem. We often load the saved *.eps files
of the plots into different layers in Adobe Illustrator for convenient
viewing, which is best done when axes are all the same. Note that the
slope-area plots are always drawn with the same axes for this reason.
>> It is most convenient to return to ArcMap and import
data using the "add stream shapefile" and "create
knickpoint shapefile" buttons.
• While you can always finagle importing these files later, it’s a bit
inconvenient. Here’s how it works. When you select "add stream
shapefile" or "create knickpoint shapefile", the Profiler Toolbar
populates a list of streams to choose from by reading the “active”
location_ij.txt file in the “arcmap_directory”. If you did not import
your stream or cluster of streams BEFORE selecting any additional
channel heads in ArcMap, then this “active” location_ij.txt file will
have been overwritten. To facilitate importing a set you forgot to do,
you need to create a “location_ij.txt” where you edit the number of
lines and the “streamname”s in the last column to match the set you
wish to import. Note that the Profiler Toolbar only reads the last
column to populate the “available streams” box, so the other columns
can have random dummy values (just copy and paste the first row for
the number of streams then edit the streamname column as needed).
• An upgrade to this function is coming soon.
6. Returning to ArcGIS.
A. Now back in Arc, you will need to download the data you just collected to visualize it in
ArcGIS and plot the data over the map. Use the profile toolbar to import your data:
B. Using the toolbar, click the third button from the left that looks like 3 curvy lines or
streams (next to “· to ML”). You will see the following screen:
16
Ch. 3 – Extracting and analyzing Profile Data
Select the stream(s) you want to import, add to the output list, and hit “Convert selected
streams to shapefiles”. Note that you can also create a single shapefile that will include
all the streams, rather than each one individually, by selecting “Append to new or
existing shapefile?”. Checking this box calls up additional windows on the dialog box
where you can either select an existing stream shapefile from the list, or type in the name
of a new one you wish to create.
C. After the stream data are imported, click the fourth button from the left that looks like
three strings of knickpoints. You will see a similar screen to the long profile import
screen, which will allow you to import your knickpoint data.
7. Advanced options
A. Note that the profiler toolbar also has an “Auto KS Import” option. Combined with the
Matlab code “profile51_batch.m”, this tool allows you to create a shapefile that will
contain either a subset of streams you pick or ALL the streams in a catchment above a
specified minimum drainage area and that can be color-coded by steepness index. Both
cases are fully automated, so it’s a quick easy way to get a first cut analysis done. IT is
also completely objective, with no “art” to where to pick regression bounds. There are
two ways to use this option:
i. Use the batch profile option is to process EVERY stream in your catchment
above a specified minimum drainage area automatically.
a. The Matlab syntax is slightly different here, as you need to tell Matlab
what your critical drainage area is which triggers matlab to search for
channel heads automatically. At the Matlab command prompt, type the
following:
>> profile51_batch(‘fname’,’arcmap_directory’,
’matlab_directory’,’n’,<crit_area>)
Here <crit_area> is a number that tells Matlab what drainage area (in
square meters) defines the top of the automatically-selected channels.
A convenient format is to type 1e8, for example. Try a large critical
area first to limit the number of channels and how long the process
takes.
b. NOTE: the auto channel head selection routine will overwrite any
existing location_ij.txt files!
c. Once you have run this code, you can go back to ArcMap and click on
the “Auto KS Import” option (see below).
d. NOTE 2: The Auto KS Import option may take a REALLY long time
to run, particularly if you have selected a small ‘crit_area’ on a large
DEM. A progress bar will appear in lower right to (a) confirm that
ArcMap is at work and not dead and (b) let you track progress.
ii. Use batch profiler code to process a number of user-selected stream profiles
a. Select channel heads manually in ArcMap as before; this creates your
location_ij.txt file
b. At the Matlab command window, type the following:
>> profile51_batch(‘fname’,’arcmap_directory’,
’matlab_directory’,’n’)
c. The ‘n’ tells Matlab that you have not yet created a “chandata” file for
your stream profiles. Matlab will now extract the stream profiles
downstream of your selected channel heads, and it will calculate a
17
Ch. 3 – Extracting and analyzing Profile Data
normalized steepness index for each point along the channel. It will
create a (large) file called ‘*ks_data.txt’
d. Go back to ArcMap and click the “Auto KS Import” button on the
profiler toolbar. This will bring up a screen like this:
e. Navigate to (or type of paste in) your “arcmap_directory” and select the
Batch KS file you just created, give your new shapefile a name, and
select “Create a shapefile for selected Auto KS data file”.
f. NOTE: This will take a little while, as ArcMap needs to process every
pixel along every stream you’ve created. Go get a cup of coffee if you
need to. A progress bar will appear in lower right to (a) confirm that
ArcMap is at work and not dead and (b) let you track progress.
18
Ch. 4 – Working with your results
1. All of your long profile figures created in Matlab are saved. The current versions of the codes
save these files as both .eps and .jpg files. It is often very useful to overlay all of these in a single
document (i.e., in Adobe Illustrator) to look at the variations in stream geometry, systematic
differences in steepness, etc. In particular, using the .eps files, you can overlay all of your slope-
area plots on one set of axes and pick out the regional upper and lower bounds on steepness
values, spatial variations in ksn, etc.
2. The purpose of the jpeg version of these figures is to allow you to view them from ArcMap by
clicking on the associated stream (all segments of a given stream will call up the same figure of
course) – note that this works only if individual stream shapefiles have been merged into one
master shapefile. You do this by using the hyperlink tool in ArcMap (the lightning bolt on the
toolbar with the zoom buttons and info button). Just select the hyperlink tool and click on the
stream of interest (with the appropriate stream shapefile loaded and visible).
3. In ArcMap, it is often useful to color-code your stream segments based on their normalized
steepness indices. Right click on your stream shapefile, select “Properties” and then select the
“Symbology” tab. You will see a screen like this:
19
Ch. 4 – Working with your results
You want to use Quantities > Graduated Colors and set Value field to ksn (of course you can also
color code by regression concavity values). Pick a color scheme that works well and spreads out
the steepness values appropriately. Click “Classify” in the mid-upper right to select among
options for setting the number of colors and the position of the color breaks. This will allow you to
look at patterns of steepness indices within your catchment to evaluate whether there might be
transients working their way through the system or breaks in steepness indices that might be
correlated with changes in tectonic uplift rates (see example below). Finding the perfect color
ramp can be an effort. Once you have one you like it is wise to save it as a Layer file that records
your settings. In the Layers side-bar in ArcMap (along the left margin by default), right click your
shapefile and select “Save as Layer File”. Once this is done, in the Symbology dialog box shown
above, you can use the “Import” button in the far upper right to import a color scheme previously
saved as a Layer File. This is highly recommended.
• http://web.mit.edu/gis/www/introarcgis/
• http://libinfo.uark.edu/GIS/tutorial.asp
• http://arrowsmith410-598.asu.edu/Lectures/Lecture9/DEM_data.html
20
Ch. 4 – Working with your results
It can be useful to load your saved matlab plots into different layers in Illustrator for direct comparison
and for plotting composites. For this to work you need to have set all plots to the same axis limits (see
item 15 above). Steps:
21
Ch. 5 – Code Architecture and Output
Below is a list of the main Matlab codes (.m files) utilized in stream profile extraction and
analysis. This is meant to be an exhaustive list of all the .m files used, their purpose, which
subroutines are called by which files, and the syntax used for each code.
arcdemtxt2matlab.m: this code is used to pre-process DEM data to create Matlab binary files
from ArcGIS ASCII output. It also creates a “metadata” file for the DEM and accumulation
grids that are read into Matlab (can be a subset of the DEM, ACCUM grid loaded in ArcMap,
but must be in same projection and the DEM and ACCUM grids must have exactly the same
extent).
profile51.m: this code is the primary function that initializes and runs the profile extraction
routine.
function[]= profile51(‘fname’,’arcmap_directory’,’matlab_directory’,’exist_cd’)
For each river analyzed, profile.m creates a matrix called chandata that stores all of the
information for that channel (plus some supplementary files, see below). chandata is a
matrix comprising a series column vectors, with each row representing the data from an
individual pixel along the channel. The columns of the chandata array are as follows:
Note that at the end of each profile analysis routine, there is an option to save the
profile’s chandata. This is saved as a Matlab binary file filename_chandata.m. If you re-
process pre-existing chandata files (‘exist_cd’ = ‘y’), then there is an option to add a
suffix to all saved files (e.g. suffix ‘v2’ would give “mydata_chandata_v2.mat”)
answer_yn: this is a simple function to return a binary flag in response to a yes/no question
(returns 1 if YES and 0 if NO)
movavg51.m: this code performs a moving average of the elevation array, within a window
of user-specified width
23
Ch. 5 – Code Architecture and Output
function[smooth_array] = movavg42(array,pixel_size,wind)
sa_analysis51.m: this code contains most of the analysis of slope/area data extracted from
the profile
function [ida,islope,lbarea,lbslope,chandata,ans2] =
sa_analysis51(chandata,movernset,name,arc_workdir,mat_workdir,rmspike,wind,no_s
tep,ks_window,cont_intv)
IF you have opted to use “step remover” one of the following is called (this option
does not allow any additional smoothing of the data).
closeto.m: this function finds the row that contains a value in a specified
column that is nearest to designated ‘value’
profile51_batch.m: this function batch processes stream profiles, constructing chandata matrices
for a group of channels simultaneously. This code can be used to batch process channels from
user-selected channel heads, or it can be used to automatically find all the channels in a network.
function [chandata] = profile51_batch(fname,arcmap_directory, matlab_directory,
exist_cd,crit_area)
24
Ch. 5 – Code Architecture and Output
function[atargi,atargj,atargx,atargy,label] = auto_chn_finder
(fname,arc_workdir,mat_workdir,accum,network,easting,northing,crit_pix)
auto_ks_calc.m: this function adds automatically calculated ksn values for each
stream segment, by forcing regressions through slope-area data over a user-specified
window length (ks_window)
function [chandata] = auto_ks_calc(chandata,movernset,cont_intv,
ks_window)
The profile extraction and analysis process generates a number of files along the way; all of these
will be stored in the Matlab and ArcMap directories that you specify at the command line when
you run profile51.m. Below is a list of the files created, and what they are.
run_parameters.txt: This file stores the values you input in the ArcMap dialog box at
the very beginning of your profile analysis. The file is just a series of numbers, which are
(in order):
(1) cellsize; (2) reference concavity; (3) spike removal option [1/0]; (4) step
removal option [1/0]; (5) smoothing option [1/0]; (6) smoothing window size; (7)
contour interval; (8) window length for auto ksn calculation; (9) Distance to run
downstream to ensure you’re in the channel; (10) Minimum accumulation area to
determine upstream extent of a channel.
location_ij.txt: This file stores the coordinates of all the starting points you select in
ArcMap, in both matrix (i,j) and geographic (lat, long) form. It has the same number of
rows as there are channel heads selected.
In addition to these “generic” files, the codes will also create the following files for each
channel you analyze (where * denotes a given channel name, i.e. “stream1”).
*.jpg: a jpeg file of the Matlab generated Figure 2 with the long profile, drainage
area vs. distance, and slope-area plots (for use with ArcMap Hyperlink tool)
*_f3.jpg: a jpeg file of the Matlab generated Figure 3 with elevation vs. χ,
gradient vs. distance, and ksn vs distance.
*_stream.txt: a text file with all of the location information for the stream in
question (drainage area; i-j coordinates; lat-long coordinates for each point along
the stream)
25
Ch. 5 – Code Architecture and Output
*_knick.txt: a text file saving the chandata values from selected knick points
*.eps: a postscript file of the Matlab generated Figure 2 with the long profile,
drainage area vs. distance, and slope-area plots.
*_f3.eps: a postscript file of the Matlab generated Figure 3 with elevation vs. χ,
gradient vs. distance, and ks vs distance.
*.chandata.mat: a Matlab binary file saving the “chandata” matrix for your
stream
*.sa_data.mat: a Matlab binary file saving the slope-area data for the channel.
*_SA_fits.mat: a Matlab binary file saving the regression parameters from the
slope-area fits
*_knick.mat: a Matlab binary file saving the chandata values from selected knick
locations
26