This docker container allows you to run the LSDTopoTools command line tools for valley extraction. It has the OpenCV dependency installed. It also allows you to run all the other LSDTopoTools command line tools.
These instructions tell you how to download the valley extraction tools and run them in a Docker environment.
These are the bare bones instructions. For a bit more detail and potential bug fixes, scroll down to the section on Docker notes.
brew cask install docker
sudo usermod -a -G docker $USER
C:\LSDTopoTools
.
Preamble: Once you have downloaded docker, you can control how much memory you give the docker containers. The default is 3Gb. If you have even moderate sized DEM data, this will not be enough. You can go into the docker settings (varies by operating system, use a search engine to figure out where they are) and increase the memory.
There are 2 options for getting the docker container so that you can run the valley extraction tools.
The first (preferred) option is to simply download and run the docker container that we have already built. To do this, just run the following command in a terminal (MacOS or Linux) or Powershell window (Windows):
Windows:
docker run -it -v C:\LSDTopoTools:/LSDTopoTools lsdtopotools/lsdtt_opencv_docker
Linux:
docker run -it -v /LSDTopoTools:/LSDTopoTools lsdtopotools/lsdtt_opencv_docker
-it
means "interactive".-v
stands for "volume" and in practice it links the files in the docker container with files in your host operating system.-v
you need to tell docker where the directories are on both the host operating system (in this case C:\LSDTopoTools
) and the container (in this case /LSDTopoTools
). These are separated by a colon (:
).Once you do this you will get a #
symbol showing that you are inside the container. You can now do LSDTopoTools stuff.
git clone https://github.com/LSDtopotools/lsdtt_opencv_docker
cd lsdtt_opencv_docker
and then build the docker file. NOTE: this will take a long time (an hour or so).
docker build -t lsdtt_opencv_docker .
$ docker run -it -v C:\LSDTopoTools:/LSDTopoTools lsdtt_opencv_docker
# lsdtt-valley-metrics -h
You will get a screen saying you need a parameter file, and it will also tell you that some help files have been generated. If you look in your current directory there will be an .html file called lsdtt-valley-metrics-README.html that has instructions on how to run the command line tool.
C:\LSDTopoTools
directory. Let's assume your parameter file is called LSDTT_valleys.param
. We would run the valley metrics algorithm by navigating to the LSDTopoTools
where the DEM is stored in docker and then run:lsdtt-valley-metrics LSDTT_valleys.param
Here is an example parameter file that will extract a valley width with the minimum amount of settings:
# File information
read fname: My_DEM
# Parameters for preprocessing
# Parameters that will change on the basis of DEM grid spacing.
# window radius should be ~3x DEM grid spacing
# threshold pixels should be ~100 for 30m DEM and a few thousand for 2m DEM
surface_fitting_window_radius: 90
threshold_contributing_pixels: 100
# Some steps to visualise outputs
write_hillshade: true
print_channels_to_csv: true
remove_seas: true
# Parameters for floodplain extraction
use_absolute_thresholds: true
relief_threshold: 10
slope_threshold: 0.05
threshold_SO: 4
fill_floodplain: true
# Parameters to get the valley centreline
channel_source_fname: coords.csv
get_valley_centreline: false
convert_csv_to_geojson: true
centreline_loops: 5
trough_scaling_factor: 0.5
extract_single_channel: true
# Parameters for valley widths
# These will depend on grid resolution.
# the bank search radius will depend on the valley width. It should be around half the width of the valley.
get_valley_widths: true
width_node_spacing: 50
valley_banks_search_radius: 50
Some things to note:
Tay.bil
and Tay.hdr
then this line needs to read read fname: Tay
. The read fname
is case sensitive. lsdtt-valley-metrics
from there. coords.csv
with the latitude,longitude
in the first row and the lat-long coordinates of the starting point of your channel in the second row. If you want to know all about Docker, make sure to read the docker documentation. A note of warning: Docker documentation is similar to documentation for the turbo encabulator. Below are some brief notes to help you with the essentials.
Here are some shortcuts if you just need a reminder of how docker works.
List all containers
$ docker ps -a
List containers with size
$ docker ps -as
Remove all unused containers
$ docker system prune
After you install docker on Linux, you will need to add users to the docker permissions:
$ sudo usermod -a -G docker $USER
Once you have done this you will need to log out and log back in again.
This section used to be very complicated, with many tips and tricks and gotchas. But Docker Desktop for Windows is much more streamlined now and you should just follow the instructions on the Docker for Windows installation website