16.4. bathy_threshold_calc.py¶
The bathy_threshold_calc.py
program takes as input a
single-channel image, for example, band 7 of a WorldView multispectral
image, and computes the threshold separating the water and land
pixels.
See Section 8.26.3 for further context, and a sample output and graph.
This tool needs Python 3 and some additional Python packages to be installed with
conda
.
Conda can be obtained from
Run:
./Miniconda3-latest-Linux-x86_64.sh
on Linux, and the appropriate version on OSX (this script needs to be made executable first). Use the suggested:
$HOME/miniconda3
directory for installation.
Next, with the conda environment activated, the needed packages can be installed as follows:
conda create --name bathy -c conda-forge python=3.6 gdal
conda activate bathy
conda install -c conda-forge numpy scipy matplotlib
This program can be invoked as:
~/miniconda3/envs/bathy/bin/python $(which bathy_threshold_calc.py) \
--image image.tif --num-samples 1000000
Here it is assumed that ASP’s bin
directory is in the path, otherwise
the full path to this Python script must be specified above.
Command-line options for bathy_threshold_calc.py:
- -h, --help
Display the help message.
- --image <filename>
The single-channel image to use to find the water-land threshold.
- --num-samples <integer (default: 1000000)>
The number of samples to pick from the image (more samples will result in more accuracy but will be slower).
- --no-plot
Do not show the plot.