This Python script allows to detect river dead wood using IGN BD Ortho data. Firstly, it calculates indexes to be added to orthophotographs. Secondly it applies the random forest model on the orthophotographs. Finally, it output a shapefile layer with dead wood polygons and their metrics. This tool only works on Windows or Linux
Firstly you need to clone the repository :
git clone https://github.com/g-grimmer/RiverDetectWood.git
cd RiverDetectWood
- Python 3.9
GDAL
Rasterio
Scipy
Joblib
Geopandas
Tqdm
- Orfeo Toolbox (OTB) version 9.x
We recommand to use Anaconda.
conda create -n myenv python=3.9
conda activate myenv
conda install -c conda-forge numpy gdal rasterio shapely geopandas scipy scikit-learn joblib tqdm
Firstly you have to install OTB from https://www.orfeo-toolbox.org/download/
Here you must execute the file otbenv.bat (or otbenv.profile on linux):
On Windows
C:\path\to\otb\bin\otbenv.bat
On Linux
On linux, you can follow the steps describe on OTB official website. Basically, you just need to source the environment profile before launching our script on the same terminal.
source /Path/To/OTB_install/otbenv.profile
If you encounter this error:
File "pyproj\\_crs.pyx", line 2378, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: EPSG:2154: (Internal Proj Error: proj_create: no database context specified)
Reinstall pyproj using pip:
pip install --force-reinstall pyproj
The RiverDetectWood tool has been tested on orthophotographs from three river basins in France: the Buech, Loire, and Doubs. These test datasets provide diverse conditions to validate the model's performance on dead wood detection in varying river environments.
python rdw_tool.py input_tiff_path model_path keep_all_outputs
In this function :
input_tiff_path
is the orthophotograph pathmodel_path
is the random forest model file pathkeep_all_outputs
, 1 to keep all outputs, 0 to delete them
If you use this repository in your research, please cite the corresponding paper:
@article{grimmer2024deadwood,
title={RiverDetectWood: A Tool for Automatic Detection and Quantification of Dead Wood in River Systems Using Very High Spatial Resolution Aerial Photographs},
author={Grimmer, Gauthier and Wenger, Romain and Chardon, Valentin},
journal={},
year={2024},
publisher={}
}