B Appendix 2: Tree 3D
The aim of this appendix is to test tree segmentation and light on the las cloud from Dicorynia guyanensis in Paracou.
B.1 Tree Segmentation
Using lidr
.
Works well to delineate the tree cloud but not build back architecture.
Can be a good step for AMAPvox.

Figure B.1: Individual segmented with lidR.
B.2 Tree architecture
The reconstruction of the architecture, i.e. rebuilding the trunk and the branches. On this point there are plenty of poorly documented, impossible to install and not so open tools. But after a long battle I managed to make treeseg
work a bit despite its lack of real documentation. And as I suspected unfortunately the data doesn’t seem to be good enough for this task. Indeed, besides the fact that we are in a complex rainforest, this reconstruction is normally done from high resolution LiDAR TLS data. But here I have only few points that represent the trunk or the main branches. The algorithm is therefore unable to reconstruct the cylinders.
B.3 Tree light
For this part I am still waiting for Nicolas to share with me the trajectos (3D path of the drone) to use AMAPvox. Nevertheless I don’t see how this will orientate more the sampling than using a device on the spot like with the Sextonia, especially if we can’t reconstruct the architecture beforehand. So I think I’ll stop here and wait for the postdoc to face this calculation for the a posteriori analysis of the mutations.
B.4 Tree Segmentation
This v explored tree segmentation with QSM on the las cloud from Dicorynia guyanensis in Paracou.
B.4.1 treeseg
Failed, and no further documentation, dropping thus treeseg
.
## Convert
# las to pcd
pdal translate YS-20201123-130625classclipDycorinia.las test.pcd --writers.pcd.order="X=Float:2,Y=Float:2,Z=Float:2" # to avoid float issue
# visualize in cloud compare
tail -n +11 test.pcd > test.xyz
# computing bounding box
Rscript -e 'summary(readr::read_delim("test.xyz", col_names = F, delim = " ")[1:2])'
echo 286791 286811 583888 583910 > test.dat
# fixing variables
# open with geany and replace X Y Z by x y z (should be further automated)
## downsample
# 1. resoluation in meters
~/Tools/treeseg/build/downsample 0.001 test.pcd # 0.04 online
~/Tools/treeseg/build/pcdPointTreeseg2txt test.tile.downsample.test.pcd
## getdemslice
# 1. the resolution of the DEM in meters
# 2) the percentile which is considered to constitute the ground (i.e., if all the points inside each DEM tile are lined up by their z coordinate - the point closest to the Nth percentile is considered the ground - sometimes useful for noisy data).
# 3)&4) The zmin and zmax of the slice. So e.g.,:
~/Tools/treeseg/build/getdemslice 1 1 0 5 test.tile.downsample.test.pcd # 2 3 3 6
~/Tools/treeseg/build/pcdPointTreeseg2txt test.slice.pcd
## Find stems
~/Tools/treeseg/build/findstems 15 0.2 2 test.dat test.slice.pcd
~/Tools/treeseg/build/pcdPointTreeseg2txt test.intermediate.slice.clusters.pcd
~/Tools/treeseg/build/pcdPointTreeseg2txt test.intermediate.slice.clusters.regions.pcd
## Segments stems
~/Tools/treeseg/build/segmentstem 12.5 test.tile.downsample.test.pcd test.intermediate.slice.clusters.regions.pcd
B.4.2 Computree
B.4.2.1 Windows version
Not working with wine when calling downsampling with SimpleTree plugin. Test on voncyane windows validated the software, to be tested on Niklas computer thursday afternoon.
cd ~/Tools/Computree
wget http://rdinnovation.onf.fr/attachments/download/2788/SimpleForest_v5.1.3_computree_v5.0.221b.zip
unzip SimpleForest_v5.1.3_computree_v5.0.221b.zip
cd SimpleForest_v5.1.3_computree_v5.0.221b/
wine CompuTreeGui.exe
- Import the cloud
- Reduce points density
- Classify ground points (TLS)
- Ground point filter
- Statistical outlier filter
- Dtm pyramidal Mlesac fit
- Cut cloud above DTM
- Cut cloud above DTM
- Cut cloud above DTM
- Stem filter
- Statistical outlier filter
- Radius outlier filter
- Segmentation euclidean clustering
- Dikstra based tree segmentation
- Voroni based tree segmentation
- Height based tree identification from segmented clouds
- Height based tree identification from segmented clouds
- Cut cloud above dtm
- Cut cloud above dtm
- Stem filter
- Euclidean clustering filter
- Merge clouds from two groups
- Statistical outlier filter
- Euclidean clustering filter
- Sphere following
- QSM median filter
- QSM based tree clustering
- Sphere following advanced
- QSM median filter
- QSM correct shoots
- QSM allometric correction
- QSM to ground exploration
- QSM list exporter
B.4.2.2 Linux version
Still failing, waiting for Alexandre Piboule feedbacks.
cd ~/Tools/Computree
sudo apt-get update
sudo apt-get install subversion
sudo apt-get install build-essential qtcreator qt5-default qt5-doc qt5-doc-html qtbase5-doc-html qtbase5-examples
wget http://rdinnovation.onf.fr/attachments/download/2378/kit_dev_linux.zip
unzip kit_dev_linux.zip
cd kit_dev_linux
./recuperer_depots.sh
sudo apt-get install libopencv-dev
sudo apt-get install libpcl-dev # pcl 1.10 need pcl 1.8
sudo apt-get install libgdal-dev
sudo apt-get install libgsl-dev
qtcreator
# > open > all.pro
# > projet > unactivate shadow build
# > projet/run > “Environnement d’exécution” > rajouter ” ;. ” à la fin de la variables LD_LIBRARY_PATH
qmake all.pro
# > pcl1.8 to pcl1.10 in code
sudo ln -s /usr/local/include/opencv4/opencv2/ /usr/local/include/opencv2 # fix opencv2/core/core.hpp issue
# > compile
# > run
B.4.3 Tree Segmentation with lidr
Works well to delineate the tree cloud but not to segment it. Can be a good step for AMAPvox.
require(lidR)
require(rlas) # Necessary for writelax
require(rgdal) # Writing to shp or raster
require(tictoc) # for tic() toc() function
require(rgl)
data <- "data/Paracou/AG/YS-20201123-130625classclipDycorinia.las"
las <- readLAS(data)
# lascheck(las)
# summary(las)
# sort(unique(las@data$Classification))
# plot(las, color = "Classification")
las_class <- lasfilter(las, Classification == 1)
# plot(las_class)
dtm <- grid_terrain(las, algorithm = knnidw(k = 8, p = 2))
las_normalized <- lasnormalize(las, dtm)
lasfilternoise = function(las, sensitivity)
{
p95 <- grid_metrics(las, ~quantile(Z, probs = 0.95), 10)
las <- lasmergespatial(las, p95, "p95")
las <- lasfilter(las, Z < p95*sensitivity)
las$p95 <- NULL
return(las)
}
las_denoised <- lasfilternoise(las_normalized, sensitivity = 1.2)
# plot(las_denoised)
# plot(las_normalized)
chm <- grid_canopy(las_denoised, 0.5, pitfree(c(0,2,5,10,15), c(3,1.5), subcircle = 0.2))
# plot_dtm3d(chm)
ker <- matrix(1,5,5)
chm_s <- focal(chm, w = ker, fun = median)
algo <- watershed(chm_s, th = 10, tol = 0.7, ext = 1)
las_watershed <- lastrees(las_denoised, algo)
trees <- lasfilter(las_watershed, !is.na(treeID))
plot(trees, color = "treeID", colorPalette = pastel.colors(100))
path <- "/home/sylvain/Documents/ECOFOG/treemutation/data/Paracou/AG/YSsegmented.gif"
movie3d(spin3d(), duration = 5, movie = path)
B.4.4 Forest Metrics
Hard to install and no better than lidR as it does not segment the crown.
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libflann-dev
sudo apt-get install libvtk6-qt-dev
sudo apt-get install libqhull-dev
sudo apt-get install libproj-dev
sudo apt autoremove
# pcl skipping 1.10
wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz
tar -xf pcl-1.8.1.tar.gz
cd pcl-pcl-1.8.1 && mkdir build && cd build
cmake ..
make
sudo make install
# ForestMetrics
git clone --recursive https://github.com/yurithefury/ForestMetrics.git ForestMetrics
cd ForestMetrics
mkdir build
cd build
cmake ..
make
B.4.5 sp4e
Segmenting cloud but no QSM.
B.4.6 TreeQSM
Mathlab, giving this one up.