1. Introduction
Terrestrial landscapes are almost all dissected by channels. Mapping channels and rivers has been a feature of cartography from its start. A few centuries ago, finding river sources use to be an amusing way to get your name in a newspaper. In fact, there continue to this day to be stunts looking for the source of major rivers.
Taking boats through precarious jungles is good fun for some, but in fact we can now use digital topography to look for the characteristic topographic signs of channels on the landscapes using remotely-sensed data. These signs can simply be the "v-shaped" valleys that you might have learned about in school, or could include more advanced techniques. We now have topographic data covering the entire planet so as long ago as 2005 (when the SRTM 90 dataset was released) it was trivially easy to find the longest channel in a river network. Knowing in detail where the channel head is, however, is not at all trivial and now that lidar data is widely available, we can look for topographic signature of channel at scaled approaching those of the actual channel heads.
In this documentation we have compiled several methods for determining the location of channel heads using high resolution data, and ported them into LSDTopoTools. These algorithms should be, for the most part, accurate to ~20-30 metres of the actual channel head. For details see the following paper:
We have also attempted to quantify the resolution of data needed for the different methods; the answer is that you might be able to extract a reasonable channel network from 10 metres resolution data, but 30 metre resolution data is not trustworthy. If you have lidar data, use that. The details are contained in the following paper:
For completeness we include our historic functions for calculating channel sources, but in general the only tool you will need is The Channel Extraction tool. We also refer readers to the GeoNet channel extraction tool, which was developed by Paola Passalacqua and colleagues.
2. Get the code for channel extraction
Our code for channel extraction can be found in our GitHub repository. This repository contains code for extracting channel networks using a variety of different methods ranging from simple contributing area thresholds to more complex geometric and theoretical approaches for extracting channels from high-resolution datasets.
2.1. Compile channel extraction using LSDTopoToolsSetup.py
2.2. Clone the GitHub repository (not needed if you used LSDTopoToolsSetup.py)
If you haven’t run our vagrant setup, you need to clone the repository. First navigate to the folder where you will keep the GitHub repository. In this example it is called /LSDTopoTools/Git_projects/. To navigate to this folder in a UNIX terminal use the cd command:
$ cd /LSDTopoTools/Git_projects/
You can use the command pwd to check you are in the right folder. Once you are in this folder, you can clone the repository from the GitHub website:
$ pwd
/LSDTopoTools/Git_projects/
$ git clone https://github.com/LSDtopotools/LSDTopoTools_ChannelExtraction.git
Navigate to this folder again using the cd command:
$ cd LSDTopoTools_ChannelExtraction/
2.3. Alternatively, get the zipped code (not needed if you used LSDTopoToolsSetup.py)
If you don’t want to use git, you can download a zipped version of the code:
$ pwd
/LSDTopoTools/Git_projects/
$ wget https://github.com/LSDtopotools/LSDTopoTools_ChannelExtraction/archive/master.zip
$ gunzip master.zip
GitHub zips all repositories into a file called master.zip,
so if you previously downloaded a zipper repository this will overwrite it.
|
2.4. Example datasets
We have provided some example datasets which you can use in order to test the channel extraction algorithms. In this tutorial we will work using a lidar dataset from Indian Creek, Ohio.
$ cd /LSDTopoTools/Topographic_projects/Test_data
The DEM is called indian_creek.bil and indian_creek.hdr, and the relevant parameter file is Vagrant_ChannelExtraction.driver.
This dataset is already in the preferred format for use with LSDTopoTools (the ENVI bil format). The figure below shows a shaded relief map of part of the Indian Creek DEM which will be used in these examples.
You can also work with the DEM gabilan.bil that is included by default in the /LSDTopoTools/Topographic_projects/Test_data folder but you will need tochange the parameter files to reflect the different DEM name.
|
3. The Channel Extraction tool
Our channel extraction tool bundles four methods of channel extraction. These are:
-
A rudimentary extraction using a drainage area threshold.
-
A geometric method combining elements of Geonet (Passalacqua et al., 2010) and Pelletier (2013) methods that we developed for Grieve et al. (2016) and Clubb et al. (2016) We call this the "Wiener" method (after the wiener filter used to preprocess the data).
These methods are run based on a common interface via the program channel_extraction_tool.exe.
3.1. Running channel extraction with a parameterfile
We assume you have compiled the channel extraction tool (if not, go back here).
Like most of LSDTopoTools, you run this program by directing it to a parameter file. The parameter file has a series of keywords. Our convention is to place the parameter file in the same directory as your data.
3.1.1. Channel extraction options
The parameter file has keywords followed by a value. The format of this file is similar to the files used in our LSDTT_BasicMetrics program, which you can read about in the our section introducing LSDTopoTools: Basic usage of LSDTopoTools.
The parameter file has a specific format, but the filename can be anything you want. We tend to use the extensions .param and .driver for these files, but you could use the extension .MyDogSpot if that tickled your fancy.
|
The parameter file has keywords followed by the : character. After that there is a space and the value.
Below are options for the parameter files. Note that all DEMs must be in ENVI bil format (DO NOT use ArcMap’s bil format: these are two different things. See the documentation on data sources if you want more details).
The reason we use bil format is because it retains georeferencing which is essential to our file output since many of the files output to csv format with latitude and longitude as coordinates.
| Keyword | Input type | Description |
|---|---|---|
write path |
string |
The path to which data is written. The code will NOT create a path: you need to make the write path before you start running the program. |
read path |
string |
The path from which data is read. |
write fname |
string |
The prefix of rasters to be written without extension.
For example if this is |
read fname |
string |
The filename of the raster to be read without extension. For example if the raster is |
channel heads fname |
string |
The filename of a channel heads file. You can import channel heads. If this is set to |
| Keyword | Input type | default | Description |
|---|---|---|---|
minimum_elevation |
float |
0 |
If you have the |
maximum_elevation |
float |
30000 |
If you have the |
remove_seas |
bool |
false |
If true, this changes extreme value in the elevation to NoData. |
raster_is_filled |
bool |
false |
If true, the code assumes the raster is already filled and doesn’t perform the filling routine. This should save some time in computation, but make sure the raster really is filled or else you will get segmentation faults! |
| Keyword | Input type | Default value | Description |
|---|---|---|---|
print_area_threshold_channels |
bool |
true |
Calculate channels based on an area threshold. |
print_dreich_channels |
bool |
false |
Calculate channels based on the dreich algorithm. |
print_pelletier_channels |
bool |
false |
Calculate channels based on the pelletier algorithm. |
print_wiener_channels |
bool |
false |
Calculate channels based on our wiener algorithm. |
| Keyword | Input type | Default value | Description |
|---|---|---|---|
print_stream_order_raster |
bool |
false |
Prints a raster with channels indicated by their strahler order and nodata elsewhere. File includes "_SO" in the filename. |
print_channels_to_csv |
bool |
true |
Prints a csv file with the channels, their channel pixel locations indicated with latitude and longitude in WGS84. |
print_sources_to_raster |
bool |
false |
Prints a raster with source pixels indicated. |
print_sources_to_csv |
bool |
true |
Prints a csv file with the sources, their locations indicated with latitude and longitude in WGS84. |
print_fill_raster |
bool |
false |
Prints the fill raster |
write hillshade |
bool |
false |
Prints the hillshade raster to file (with "_hs" in the filename). |
print_wiener_filtered_raster |
bool |
false |
Prints the raster after being filter5ed by the wiener filter to file. |
print_curvature_raster |
bool |
false |
Prints two rasters of tangential curvature. One is short and one long wave (has "_LW" in name) curvature. |
| Keyword | Input type | Default value | Description |
|---|---|---|---|
min_slope_for_fill |
float |
0.0001 |
Minimum slope between pixels used by the filling algorithm. |
surface_fitting_radius |
float |
6 |
Radius of the polyfit window over which to calculate slope and curvature. |
curvature_threshold |
float |
0.01 |
Threshold curvature for channel extraction. Used by Pelletier (2013) algorithm. |
minimum_drainage_area |
float |
400 |
Used by Pelletier (2013) algorithm as the minimum drainage area to define a channel. In m2 |
pruning_drainage_area |
float |
1000 |
Used by the wiener and driech methods to prune the drainage network. In m2 |
threshold_contributing_pixels |
int |
1000 |
Used to establish an initial test network, and also used to create final network by the area threshold method. |
connected_components_threshold |
int |
100 |
Minimum number of connected pixels to create a channel. |
A_0 |
float |
1 |
The A0 parameter (which nondimensionalises area) for chi analysis. This is in m2. Used by Dreich. |
m_over_n |
float |
0.5 |
The m/n paramater (sometimes known as the concavity index) for calculating chi. Used only by Dreich. |
number_of_junctions_dreich |
int |
1 |
Number of tributary junctions downstream of valley head on which to run DrEICH algorithm. |
3.1.2. Example channel extraction parameter file
Below is an example parameter file. This file is included in the repository along with the driver functions.
# Parameters for channel extraction
# Comments are preceeded by the hash symbol
# Documentation can be found here:
# TBA
# These are parameters for the file i/o
# IMPORTANT: You MUST make the write directory: the code will not work if it doesn't exist.
read path: /LSDTopoTools/Topographic_projects/test_data
write path: /LSDTopoTools/Topographic_projects/test_data
read fname: gabilan
write fname: gabilan
channel heads fname: NULL
# Parameter for filling the DEM
min_slope_for_fill: 0.0001
# Parameters for selecting channels and basins
# threshold_contributing_pixels: 2500
print_area_threshold_channels: false
print_wiener_channels: false
print_pelletier_channels: false
print_dreich_channels: true
# write hillshade: true
print_stream_order_raster: true
4. Channel extraction using thresholds
One of the simplest ways of extracting channel networks from DEMs uses a contributing area threshold. This method is useful for coarse resolution (e.g. >10m) DEMs, where topographic features of the channel heads themselves cannot be reliably identified from the DEM. The user has to specify the threshold area, which represents the upstream area that must drain to a pixel before it is considered as part of the channel.
| The area threshold chosen will affect the density of the channel network. This should be considered carefully, and compared against field-mapped channel head data if these are available. |
4.1. Extracting the network with an area threshold using the Channel extraction tool
-
To extract a network using a threshold area, you need to switch on the
print_area_threshold_channelsoption. -
The parameter file will look something like this:
# Parameters for channel extraction # Comments are preceeded by the hash symbol # Documentation can be found here: # TBA # These are parameters for the file i/o # IMPORTANT: You MUST make the write directory: the code will not work if it doens't exist. read path: /LSDTopoTools/Topographic_projects/test_data write path: /LSDTopoTools/Topographic_projects/test_data read fname: gabilan write fname: gabilan channel heads fname: NULL # Parameter for filling the DEM min_slope_for_fill: 0.0001 # Parameters for selecting channels and basins threshold_contributing_pixels: 2500 print_area_threshold_channels: true # Printing of the data write hillshade: true print_stream_order_raster: true print_channels_to_csv: true -
Save this parameter file in the directory with the data (i.e., in
/LSDTopoTools/Topographic_projects/test_data). Call it something sensible. -
Now got into the directory with the chi mapping tool (i.e.,
/LSDTopoTools/Git_projects/LSDTopoTools_ChannelExtraction/driver_functions_ChannelExtraction) and run:$ ./channel_extraction_tool.exe /LSDTopoTools/Topographic_projects/test_data NAME_OF_PARAMFILE.driver -
This should print out both a raster of stream orders and a hillshade raster, and in addition a
csvfile with channel nodes. If you import thiscsvinto a GIS you should select the coordinate system WGS84.
4.2. Basic channel extraction using thresholds (the old way)
One of the simplest ways of extracting channel networks from DEMs uses a contributing area threshold. This method is useful for coarse resolution (e.g. >10m) DEMs, where topographic features of the channel heads themselves cannot be reliably identified from the DEM. The user has to specify the threshold area, which represents the upstream area that must drain to a pixel before it is considered as part of the channel.
| The area threshold chosen will affect the density of the channel network. This should be considered carefully, and compared against field-mapped channel head data if these are available. |
We will work through an example using the Indian Creek example dataset that you downloaded.
4.2.1. Compile the code
We can extract threshold area channel networks using the driver function called channel_extraction_area_threshold.cpp. To compile the code you first need to navigate to the driver functions folder in the repository.
$ cd driver_functions_ChannelExtraction/
When in this folder type the following to compile the driver:
$ make -f channel_extraction_area_threshold.make
This will create a program called channel_extraction_area_threshold.out
4.2.2. Run the analysis
To run the analysis you first need to create a parameter file, with which we will set the key user-defined parameters. To create your parameter file, open any text editor and create a file with the following lines:
Name of the DEM without extension
Minimum slope for filling the DEM (suggested to be 0.0001)
Threshold area for channel extraction
The threshold area must be given in m2. You need to save this parameter file in the folder LSDTopoTools_ChannelExtraction (one folder above the driver functions folder). For the Indian Creek site we can create a parameter file called indian_creek_threshold.driver with the following lines:
indian_creek
0.0001
1000
After creating the parameter file we can then run the code using the following command:
$ ./channel_extraction_area_threshold.out /path_to_repository_folder/ param_file_name
For our Indian Creek example our command would be:
$ ./channel_extraction_area_threshold.out /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/ indian_creek_threshold.driver
Once this program has run, it will create several files with the extracted channel network. These include:
-
A CSV file with the channel heads e.g.
indian_creek_CH_nodeindices_for_arc.csv -
A
bilfile with the channel heads e.g.indian_creek_CH.bil -
A
bilfile with the stream network with Strahler stream ordering e.g.indian_creek_SO.bil
The figure below shows the extracted channel network for the Indian Creek field site with a threshold of 1000 m2.
5. Geometric channel extraction method
For higher-resolution DEMs a number of different methods have been developed to extract channel networks more accurately. This section details how to extract channels using methods relying on geometric signatures of channel incision, primarily how it affects planform curvature. Although many methods have been developed that use a variety of planform curvature to detect channel heads, we will discuss three methods: the Geonet method the Geonet method (developed by Passalacqua et al. 2010a, b, 2012), a method developed by Pelletier (2013) and implemented in LSDTopoTools, and a similar geometric method available within LSDTopoTools.
To run the Dreich algorithm you need to have the Fast Fourier Transform Library downloaded into your folder LSDTopoTools_ChannelExtraction. You can download it at http://www.fftw.org/download.html. If you have followed our installation instructions this will already be installed on your system.
|
5.1. Extracting the network with geometric methods using the Channel extraction tool
-
The Channel extraction tool has two "geometric" channel extraction options.
-
To extract a network using the Pelletier methods, you need to switch on the
print_pelletier_channelsoption. -
To extract a network using the LSDTopoTools Wiener filter method, you need to switch on the
print_wiener_channelsoption. This method was used by Grieve et al., ESURF, 2016 in an attempt to balance what we feel are the strongest components of the Pelletier (2013) and Geonet (by Passalacqua et al) methods.
-
-
The parameter file will look something like this:
# Parameters for channel extraction # Comments are preceeded by the hash symbol # These are parameters for the file i/o # IMPORTANT: You MUST make the write directory: the code will not work if it doens't exist. read path: /LSDTopoTools/Topographic_projects/test_data write path: /LSDTopoTools/Topographic_projects/test_data read fname: gabilan write fname: gabilan channel heads fname: NULL # Parameter for filling the DEM min_slope_for_fill: 0.0001 # Parameters for selecting channels and basins threshold_contributing_pixels: 1000 print_pelletier_channels: true print_wiener_channels: true # Printing of the data write hillshade: true print_stream_order_raster: true print_channels_to_csv: true -
In the above parameter file, I’ve used mostly defaults, with the exception of
print_dreich_channels: true. -
Save this parameter file in the directory with the data (i.e., in
/LSDTopoTools/Topographic_projects/test_data). Call it something sensible. -
Now got into the directory with the chi mapping tool (i.e.,
/LSDTopoTools/Git_projects/LSDTopoTools_ChannelExtraction/driver_functions_ChannelExtraction) and run:$ ./channel_extraction_tool.exe /LSDTopoTools/Topographic_projects/test_data NAME_OF_PARAMFILE.driver -
This should print out both a raster of stream orders and a hillshade raster, and in addition a
csvfile with channel nodes. If you import thiscsvinto a GIS you should select the coordinate system WGS84.
5.2. Geometric channel extraction methods (the old way)
For higher-resolution DEMs a number of different methods have been developed to extract channel networks more accurately. This section details how to extract channels using methods relying on geometric signatures of channel incision, primarily how it affects planform curvature. Although many methods have been developed that use a variety of planform curvature to detect channel heads, we will discuss three methods: the Geonet method the Geonet method (developed by Passalacqua et al. 2010a, b, 2012), a method developed by Pelletier (2013) and implemented in LSDTopoTools, and a similar geometric method available within LSDTopoTools.
5.2.1. Geonet (external software)
The Geonet algorithm filters the DEM using a Perona-Malik filter, then uses a planform curvature threshold which is statistically derived from the landscape to detect channel heads. For full information on how Geonet works please see Passalcqua et al. (2010a, b, 2012). It then uses a contributing area threshold to thin the skeleton and create the final channel network. The Geonet algorithm is available free to download from the Geonet website. This site also contains the code documentation and user guides on how to get started with Geonet. It is a cross platform MATLAB package (you will need a MATLAB licence to run in its present form).
5.2.2. Pelletier
Pelletier (2013) developed an algorithm that is similar to Geonet in that it identifies channel heads based on a planform curvature threshold. The main differences between this algorithm and Geonet are:
-
It uses an optimal Wiener threshold to filter the data rather than a Perona-Malik filter
-
It sets a user-defined curvature threshold (e.g. 0.1 m-1) rather than defining it statistically for the landscape in question
-
It does not use a contributing area threshold to thin the skeleton - instead it uses a multi-directional flow routing algorithm
The Pelletier algorithm has been implemented in LSDTopoTools. In order to run it you should follow the steps below.
To run the Pelletier algorithm you need to have the Fast Fourier Transform Library downloaded into your folder LSDTopoTools_ChannelExtraction. You can download it at http://www.fftw.org/download.html. If you have followed our installation instructions this will already be installed on your system.
|
Compile the code
To compile the code navigate to the folder driver_functions_ChannelExtraction. In a terminal window type the following to compile the driver:
$ make -f channel_extraction_pelletier.make
This will create a program called channel_extraction_pelletier.out which you can use to run the code.
Run the analysis
We first need to create a parameter file. To create your parameter file, open any text editor and create a file with the following lines:
Name of the DEM without extension
Minimum slope for filling the DEM (suggested to be 0.0001)
Threshold area for initial channel network (should be small e.g. 250)
Curvature threshold for channel extraction (suggested by Pelletier (2013) to be 0.1 to avoid extracting threshold hillslopes)
Minimum catchment area (suggested to be 400)
You need to save this parameter file in the folder LSDTopoTools_ChannelExtraction (one folder above the driver functions folder). For the Indian Creek site we can create a parameter file called indian_creek_pelletier.driver with the following lines:
indian_creek
0.0001
250
0.1
400
After creating the parameter file we can then run the code using the following command:
$ ./channel_extraction_pelletier.out /path_to_repository_folder/ param_file_name
For our Indian Creek example our command would be:
$ ./channel_extraction_pelletier.out /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/ indian_creek_pelletier.driver
Once this program has run, it will create several files with the extracted channel network. These include:
-
A CSV file with the channel heads e.g.
indian_creek_CH_Pelletier_nodeindices_for_arc.csv -
A
bilfile with the channel heads e.g.indian_creek_CH_Pelletier.bil -
A
bilfile with the stream network with Strahler stream ordering e.g.indian_creek_SO_Pelletier.bil
The figure below shows the extracted channel network using the Pelletier algorithm for the Indian Creek field site with a planform curvature threshold of 0.1 m-1.
5.2.3. The LSDTopoTools geometric method
Within LSDTopoTools we have also developed a method for extracting channel heads via planform curvature. We first of all filter the DEM using an Optimal Wiener filter, then use a quantile-quantile threshold to statistically determine the planform curvature threshold from the landscape. It then uses a connected components threshold to extract the channel network.
To run the LSDTopoTools algorithm you need to have the Fast Fourier Transform Library downloaded into your folder LSDTopoTools_ChannelExtraction. You can download it at http://www.fftw.org/download.html. If you have followed our installation instructions this will already be installed on your system.
|
Compile the code
To compile the code navigate to the folder driver_functions_ChannelExtraction. In a terminal window type the following to compile the driver:
$ make -f channel_extraction_wiener.make
This will create a program called channel_extraction_wiener.out which you can use to run the code.
5.2.4. Run the analysis
We first need to create a parameter file. To create your parameter file, open any text editor and create a file with the following lines:
Path and file name of the DEM without extension
Path and output name prefix for your files
Path and output name prefix for the quantile-quantile information
Window radius for filtering the DEM
Threshold area for thinning the channel skeleton
Connected components threshold (should be 100)
The threshold area is given in m2. You need to save this parameter file in the folder LSDTopoTools_ChannelExtraction (one folder above the driver functions folder). For the Indian Creek site we can create a parameter file called indian_creek_wiener.driver with the following lines:
RasterFile /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/indian_creek
OutputRasterFile /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/indian_creek
QQFile /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/indian_creek_qq
window_radius_for_surface_fitting 6
threshold_drainage_area 1000
connected_components_threshold 100
After creating the parameter file we can then run the code using the following command:
$ ./channel_extraction_wiener.out /path_to_repository_folder/ param_file_name
For our Indian Creek example our command would be:
$ ./channel_extraction_wiener.out /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/ indian_creek_wiener.driver
Once this program has run, it will create several files with the extracted channel network. These include:
-
A CSV file with the channel heads e.g.
indian_creek_CH_wiener_nodeindices_for_arc.csv -
A
bilfile with the channel heads e.g.indian_creek_CH_wiener.bil -
A
bilfile with the stream network with Strahler stream ordering e.g.indian_creek_SO_wiener.bil
The figure below shows the extracted channel network using the LSDTopoTools geometric algorithm with an Optimal Wiener filter for the Indian Creek field site.
6. Channel extraction using the Driech method
The Dreich method of channel head extraction aims to find channel heads by looking at the break in the properties of topographic profiles that occur when fluvial incision gives way to hillslope sediment transport processes. It is different from the geometric methods described above in that it looks for a theoretical signal of fluvial incision rather than the planform curvature of the landscape. The method you use should be chosen based on the particular aims of your study: if you are interested in extracting the valley network (all concave parts of the landscape) then you should use a geometric method, but if you are interested in extracting the fluvial channel network then you should use the Dreich method.
The stable version of the Dreich algorithm that was released with our WRR paper is hosted on CSDMS. The version available from our GitHub repository is the newest version of the code containing some improvements over the stable version. We have made some changes to the way that valleys are extracted from the DEM before the Dreich algorithm is run. In our previous version we used a curvature threshold of 0.1 m-1 to select valleys for analysis as a pre-processing stage. We have now changed the code so that this curvature threshold is statistically derived from the landscape in question using the same method as that of the Geonet algorithm (Passalacqua et al., 2010a, b, 2012). After the initial valley network is extracted, the user may then select the stream order of valleys in which to run the DrEICH algorithm.
To run the Dreich algorithm you need to have the Fast Fourier Transform Library downloaded into your folder LSDTopoTools_ChannelExtraction. You can download it at http://www.fftw.org/download.html. If you have followed our installation instructions this will already be installed on your system.
|
6.1. Extracting the network with the Driech method using the Channel extraction tool
-
To extract a network using the DrEICH method, you need to switch on the
print_dreich_channelsoption. -
The parameter file will look something like this:
# Parameters for channel extraction # Comments are preceeded by the hash symbol # These are parameters for the file i/o # IMPORTANT: You MUST make the write directory: the code will not work if it doens't exist. read path: /LSDTopoTools/Topographic_projects/test_data write path: /LSDTopoTools/Topographic_projects/test_data read fname: gabilan write fname: gabilan channel heads fname: NULL # Parameter for filling the DEM min_slope_for_fill: 0.0001 # Parameters for selecting channels and basins threshold_contributing_pixels: 1000 print_dreich_channels: true surface_fitting_radius: 6 number_of_junctions_dreich: 1 connected_components_threshold: 100 m_over_n: 0.5 # Printing of the data write hillshade: true print_stream_order_raster: true print_channels_to_csv: true -
In the above parameter file, I’ve used mostly defaults, with the exception of
print_dreich_channels: true. -
Save this parameter file in the directory with the data (i.e., in
/LSDTopoTools/Topographic_projects/test_data). Call it something sensible. -
Now got into the directory with the chi mapping tool (i.e.,
/LSDTopoTools/Git_projects/LSDTopoTools_ChannelExtraction/driver_functions_ChannelExtraction) and run:$ ./channel_extraction_tool.exe /LSDTopoTools/Topographic_projects/test_data NAME_OF_PARAMFILE.driver -
This should print out both a raster of stream orders and a hillshade raster, and in addition a
csvfile with channel nodes. If you import thiscsvinto a GIS you should select the coordinate system WGS84.
6.2. Channel extraction using the Dreich method (the old way)
6.2.1. Run the chi analysis
Before the Dreich algorithm can be run the m/n value for the landscape must be determined. This can be done using the chi analysis tools in LSDTopoTools.
6.2.2. Compile the code
We can extract threshold area channel networks using the driver function called channel_extraction_dreich.cpp. To compile the code you first need to navigate to the driver functions folder in the repository. When in this folder type the following to compile the driver:
$ make -f channel_extraction_dreich.make
This will create a program called channel_extraction_dreich.out
6.2.3. Run the analysis
We first need to create a parameter file. To create your parameter file, open any text editor and create a file with the following lines:
Path and file name of the DEM without extension
Path and output name prefix for your files
Window radius for filtering the DEM
Threshold area for initial channel network (should be 1000)
Connected components threshold for initial valley network (should be 100)
A_0 for chi analysis (should be 1000)
m/n value for landscape (calculate using Chi analysis tools)
Number of tributary junctions downstream of valley head to run DrEICH algorithm on (set to 1 for whole valley network)
You need to save this parameter file in the folder LSDTopoTools_ChannelExtraction (one folder above the driver functions folder). For the Indian Creek site we can create a parameter file called indian_creek_dreich.driver with the following lines:
RasterFile /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/indian_creek
OutputRasterFile /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/indian_creek
window_radius_for_surface_fitting 6
threshold_drainage_area 1000
connected_components_threshold 100
A_0 1000
m_over_n 0.437
number_of_junctions_dreich 1
After creating the parameter file we can then run the code using the following command:
$ ./channel_extraction_dreich.out /path_to_repository_folder/ param_file_name
For our Indian Creek example our command would be:
$ ./channel_extraction_dreich.out /home/LSDTT_repositories/LSDTopoTools_ChannelExtraction/ indian_creek_dreich.driver
Once this program has run, it will create several files with the extracted channel network. These include:
-
A
bilfile with the valley network with Strahler stream ordering e.g.indian_Creek_SO_valley.bil -
A CSV file with the channel heads e.g.
indian_creek_CH_DrEICH_nodeindices_for_arc.csv -
A
bilfile with the channel heads e.g.indian_creek_CH_DrEICH.bil -
A
bilfile with the stream network with Strahler stream ordering e.g.indian_creek_SO_DrEICH.bil
The figure below shows the extracted channel network using the DrEICH algorithm for the Indian Creek field site.
7. Calculating drainage density
Drainage density is a fundamental landscape metric which describes the total length of channels in a basin normalised by the basin area, first described by Horton (1945). In this chapter we describe how to calculate the drainage density and mean hilltop curvature of a specified order of drainage basins (for example, all second order basins). We also include code which will calculate the drainage density of each basin given a list of cosmogenic radionuclide (CRN)-derived erosion rate data. We used this code to examine the relationship between drainage density and erosion rate in our paper published in JGR Earth Surface in 2016.
Citation: Clubb, F. J., S. M. Mudd, M. Attal, D. T. Milodowski, and S. W. D. Grieve (2016), The relationship between drainage density, erosion rate, and hilltop curvature: Implications for sediment transport processes, J. Geophys. Res. Earth Surf., 121, doi:10.1002/2015JF003747.
7.1. Get the code for drainage density analysis
The code for the drainage density analysis can be found in our GitHub repository. This repository contains code for extracting the drainage density for a series of basins defined by points from cosmogenic radionuclide samples, as well as the drainage density and mean hilltop curvature for basins of a specified order.
7.1.1. Clone the GitHub repository
First navigate to the folder where you will keep the GitHub repository. If you have downloaded LSDTopoTools using vagrant, then this should be in the folder Git_projects. Please refer to the documentation on installing LSDTopoTools. To navigate to this folder in a UNIX terminal use the cd command:
vagrant@vagrant-ubuntu-precise-32:/$ cd /LSDTopoTools
vagrant@vagrant-ubuntu-precise-32:/$ cd /Git_projects
You can use the command pwd to check you are in the right folder. Once you are in this folder, you can clone the repository from the GitHub website:
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects$ pwd
/LSDTopoTools/Git_projects
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects$ git clone https://github.com/LSDtopotools/LSDTopoTools_DrainageDensity.git
Navigate to this folder again using the cd command:
$ cd LSDTopoTools_DrainageDensity/
7.1.2. Alternatively, get the zipped code
If you don’t want to use git, you can download a zipped version of the code:
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects$ pwd
/LSDTopoTools/Git_projects
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects$ wget https://github.com/LSDtopotools/LSDTopoTools_DrainageDensity/archive/master.zip
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects$ gunzip master.zip
GitHub zips all repositories into a file called master.zip,
so if you previously downloaded a zipper repository this will overwrite it.
|
7.1.3. Get the example datasets
We have provided some example datasets which you can use in order to test the drainage density analysis. In this tutorial we will work using a LiDAR dataset from the Guadalupe Mountains, New Mexico. This is a clip of the original dataset, which we have resampled to 2 m resolution. The full dataset is available from OpenTopography.. If you are using the vagrant distribution, create a new folder within the Topographic_projects folder, and then navigate to this folder:
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Topographic_projects$ mkdir Guadalupe_NM
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Topographic_projects$ cd Guadalupe_NM/
You can get the clip from our ExampleTopoDatasets repository using wget:
$ wget https://github.com/LSDtopotools/ExampleTopoDatasets/raw/master/Guadalupe_DEM.bil
$ wget https://github.com/LSDtopotools/ExampleTopoDatasets/raw/master/Guadalupe_DEM.hdr
This dataset is already in the preferred format for use with LSDTopoTools (the ENVI bil format). The figure below shows a shaded relief map of part of the Guadalupe Mountains DEM which will be used in these examples.
7.1.4. Get the example parameter files
We have also provided some examples parameter files that are used to run the drainage density analysis. These should be placed in the same folder as your DEM (e.g. in the folder /LSDTopoTools/Topographic_projects/Guadalupe_NM/. You can get the example parameter file using wget:
$ wget https://github.com/LSDtopotools/ExampleTopoDatasets/tree/master/example_parameter_files/drainage_density_guadalupe.driver
7.1.5. Python scripts
We have also provided some Python scripts for creating figures from the draiange density analysis. These should produce similar figures to those in Clubb et al. (2016), JGR-ES. These scripts are in the directory Python_scripts within LSDTopoTools_DrainageDensity:
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects/LSDTopoTools_DrainageDensity$ cd Python_scripts
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects/LSDTopoTools_DrainageDensity/Python_scripts$ ls
drainage_density_plot.py drainage_density_plot_cosmo.py
7.2. Preliminary steps
7.2.1. Getting the channel head file
Before the drainage density analysis can be run, you must create a channel network for your DEM. This can be done using any of the channel extraction algorithms within LSDTopoTools. Once you have run the channel extraction algorithm, you must make sure that the bil and hdr files with the channel head locations are placed in the same folder as the DEM you intend to use for the drainage density analysis.
7.2.2. Selecting a window size
Before we can run the drainage density algorithm, we need to calculate the correct window size for calculating mean hilltop curvature across the DEM. Please refer to the selecting a window size section for information on how to calculate a window size for your DEM.
7.3. Analysing drainage density for all basins
This section provides instructions for how to extract the drainage density and mean hilltop curvature for every basin in the landscape of a given order (e.g. all second order drainage basins).
7.3.1. Creating the paramter file
In order to run the drainage density analysis code you must first create a parameter file for your DEM. This should be placed in the same folder as your DEM and the channel heads bil file. If you followed the instructions in the Get the code for drainage density analysis section then you will already have an example parameter file for the Guadalupe Mountains DEM called drainage_density_guadalupe.driver. Parameter files should have the following structure:
Name of the DEM without extension
Name of the channel heads file - will vary depending on your channel extraction method
Minimum slope for filling the DEM
Order of basins to extract
Window size (m): calculate for your DEM resolution
An example parameter file for the Guadalupe Mountains DEM is set out below:
Guadalupe_DEM
Guadalupe_DEM_CH_DrEICH
0.0001
2
6
7.3.2. Step 1: Get the junctions of all the basins
The first step of the analysis creates a text file with all the junction numbers of the basins of the specified stream order. Before the code can be run, you must compile it using the makefile in the folder LSDTopoTools_DrainageDensity/driver_functions_DrainageDensity. Navigate to the folder using the command:
$ cd driver_functions_DrainageDensity/
and compile the code with:
$ make -f drainage_density_step1_junctions.make
This may come up with some warnings, but should create the file drainage_density_step1_junctions.out. You can then run the program with:
$ ./drainage_density_step1_junctions.out /path/to/DEM/location/ name_of_parameter_file.driver
For our example, the command would be:
$ ./drainage_density_step1_junctions.out /LSDTopoTools/Topographic_projects/Guadalupe_NM/ drainage_density_guadalupe.driver
The program will create a text file called DEM_name_DD_junctions.txt which will be ingested by step 2 of the analysis. It will also create some new rasters:
-
DEM_name_fill: the filled DEM
-
DEM_name_HS: a hillshade of the DEM
-
DEM_name_SO: the channel network
-
DEM_name_JI: the locations of all the tributary junctions
-
DEM_name_CHT: the curvature for all the hilltops in the DEM
7.3.3. Step 2: Get the drainage density of each basin
The second step of the analysis ingests the junctions text file created in step 1. For each junction it will extract the upstream drainage basin, and calculate the drainage density and mean hilltop curvature for the basin. This will be written to a text file which can be plotted up using our Python script.
First, compile the code with the makefile:
$ make -f drainage_density_step2_basins.make
This may come up with some warnings, but should create the file drainage_density_step2_basins.out. You can then run the program with:
$ ./drainage_density_step2_basins.out /path/to/DEM/location/ name_of_parameter_file.driver
For our example, the command would be:
$ ./drainage_density_step2_basins.out /LSDTopoTools/Topographic_projects/Guadalupe_NM/ drainage_density_guadalupe.driver
This program will create 2 text files. The first one will be called DEM_name_drainage_density_cloud.txt and will have 3 rows:
-
Drainage density of the basin
-
Mean hilltop curvature of the basin
-
Drainage area of the basin
This text file represents the data for every basin in the DEM. The second text file will be called DEM_name_drainage_density_binned.txt, where the drainage density and hilltop curvature data has been binned with a bin width of 0.005 m-1. It has 6 rows:
-
Mean hilltop curvature for the bin
-
Standard deviation of curvature
-
Standard error of curvature
-
Drainage density for the bin
-
Standard deviation of drainage density
-
Standard error of drainage density
These text files are read by drainage_density_plot.py to create plots of the drainage density and mean hilltop curvature. The code also produces DEM_name_basins.bil, which is a raster with all the basins analysed.
7.3.4. Step 3: Plotting the data
Navigate to the folder Python_scripts within the LSDTopoTools_DrainageDensity repository. You should find the following files:
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects/LSDTopoTools_DrainageDensity/Python_scripts$ ls
drainage_density_plot.py drainage_density_plot_cosmo.py
Open the file called drainage_density_plot_cosmo.py. We suggest doing this on your host machine rather than the virtual machine: for instructions about how to install Python on your host machine please see the section on the LSDTopoTools python toolchain.
Open the file called drainage_density_plot.py. We suggest doing this on your host machine rather than the virtual machine: for instructions about how to install Python on your host machine please see the section on the LSDTopoTools python toolchain.
If you want to run the script on the example dataset you can just run it without changing anything. The script will create the file Guadalupe_DEM_drainage_density_all_basins.png in the same folder as your DEM is stored in. If you want to run it on your own data, simply open the Python script in your favourite text editor. At the bottom of the file you need to change the DataDirectory (Line 165) and the DEM identifier (Line 167) to reflect your data:
# Set the data directory here - this should point to the folder with your DEM
DataDirectory = 'C:\\vagrantboxes\\LSDTopoTools\\Topographic_projects\\Guadalupe_NM\\'
# Name of the DEM WITHOUT FILE EXTENSION
DEM_name = 'Guadalupe_DEM'
make_plots(DataDirectory, DEM_name)
You should end up with a plot like the one below:
7.3.5. Summary
You should now be able to extract the drainage density and mean hilltop curvature for all basins of a given order for your DEM, and use Python to plot the results.
7.4. Analysing drainage density for basins with CRN-derived erosion rates
This section provides instructions for how to extract the drainage density for basins upstream of a series of point locations, such as cosmogenic radionuclide (CRN)-derived erosion rate samples. As an example, we will use the erosion rate data collected by Hurst et al. (2012) and Riebe et al. (2000) for the Feather River, Northern California. The lidar data for this area is available from OpenTopography. We haven’t included it in our example datasets as it is too large, but information on how to convert it into the right format can be found in our section on GDAL.
7.4.1. Formatting your erosion rate data
The program needs to read in a text file with the erosion rate data. This file needs to be called DEM_name_cosmo.txt where DEM_name is the name of the DEM without extension. The file should have a row for each sample, with 4 columns, each separated by a space:
-
X coordinate - same as DEM coordinate system
-
Y coordinate - same as DEM coordinate system
-
Erosion rate of the sample
-
Error of the sample
An example of the file for the Feather River is shown below (UTM Zone 10N):
640504.269 4391321.669 125.9 23.2
647490.779 4388656.033 253.8 66.6
648350.747 4388752.059 133.3 31.9
643053.985 4388961.321 25.2 2.7
643117.485 4389018.471 18.5 2
...
This file has to be stored in the same folder as your DEM.
7.4.2. Creating the paramter file
Along with the text file with the erosion rate data, you must also create a parameter file to run the code with. This should have the same format as the parameter file for running the analysis on all the basins, minus the last two lines. The format is shown below:
Name of the DEM without extension
Name of the channel heads file - will vary depending on your channel extraction method
Minimum slope for filling the DEM
This should also be stored in the same folder as your DEM.
7.4.3. Step 1: Run the code
Before the code can be run, you must compile it using the makefile in the folder LSDTopoTools_DrainageDensity/driver_functions_DrainageDensity. Navigate to the folder using the command:
$ cd driver_functions_DrainageDensity/
and compile the code with:
$ make -f get_drainage_density_cosmo.make
This may come up with some warnings, but should create the file get_drainage_density_cosmo.out. You can then run the program with:
$ ./get_drainage_density_cosmo.out /path/to/DEM/location/ name_of_parameter_file.driver
where /path/to/DEM/location is the path to your DEM, and name_of_parameter_file.driver is the name of the parameter file you created.
The program will create a text file called DEM_name_drainage_density_cosmo.txt which can be ingested by our Python script to plot up the data. This file has 9 rows with the following data:
-
Drainage density of the basin
-
Mean basin slope
-
Standard deviation of slope
-
Standard error of slope
-
Basin erosion rate
-
Error of the basin erosion rate
-
Basin drainage area
-
Mean hilltop curvature of the basin
-
Standard error of hilltop curavture
It will also create some new rasters:
-
DEM_name_slope: slope of the DEM
-
DEM_name_curv: curvature of the DEM
7.4.4. Step 2: Plot the data
Navigate to the folder Python_scripts within the LSDTopoTools_DrainageDensity repository. You should find the following files:
vagrant@vagrant-ubuntu-precise-32:/LSDTopoTools/Git_projects/LSDTopoTools_DrainageDensity/Python_scripts$ ls
drainage_density_plot.py drainage_density_plot_cosmo.py
Open the file called drainage_density_plot_cosmo.py. We suggest doing this on your host machine rather than the virtual machine: for instructions about how to install Python on your host machine please see the section on [Getting python running].
Open the Python script in your favourite text editor. At the bottom of the file you need to change the DataDirectory (Line 131) and the DEM identifier (Line 133) to reflect your data:
# change this to the path to your DEM
DataDirectory = 'C:\\vagrantboxes\\LSDTopoTools\\Topographic_projects\\Feather_River\\'
# Name of the DEM WITHOUT FILE EXTENSION
DEM_name = 'fr1m_nogaps'
make_plots(DataDirectory, DEM_name)
You should end up with a plot like the one below:
7.4.5. Summary
You should now be able to extract the drainage density for a series of different basins across the landscape. These can either be all basins of a specific order (Step 1), or basins defined by point coordinates (e.g. for catchment-averaged erosion rates from CRN samples in Step 2).