Learn R Programming

TreeLS

High performance R functions for forest data processing based on Terrestrial Laser Scanning (but not only) point clouds.

Description

This package is a refactor of the methods described in this paper, among many other features for 3D point cloud processing of forest environments.

Most algorithms are written in C++ and wrapped in R functions through Rcpp. TreeLS is built on top of lidR, using its LAS infrastructure internally for most methods.

For any questions, comments or bug reports please submit an issue here on GitHub. Suggestions, ideas and references of new algorithms are always welcome - as long as they fit into TreeLS' scope.

TreeLS is currently on v2.0. To install it from an official mirror, use: install.packages("TreeLS"). To install the most recent version, check out the Installation from source section below.

*TreeLS is not on CRAN at the moment (August/2020), the up-to-date version is submitted and should be available shortly. Meanwhile you can install it from source using devtools.

News

  • August/2020: Version 2.0 is finally available! It's a major release, introducing several new functionalities, bug fixes, more robust estimators for noisy clouds and more flexible plotting. All functionalities from older versions are now available and optimized, so there should be no need to use legacy code anymore. The scope of application of TreeLS has become much wider in this version, specially due to the introduction of functions like fastPointMetrics and shapeFit, making it much easier for researchers to assess point cloud data in many contexts and develop their own methods on top of those functions. For a comprehensive list of the updates check out the CHANGELOG.

  • March/2019: TreeLS is finally available on CRAN and is now an official R package.

Main functionalities

  • Tree detection at plot level
  • Tree region assignment
  • Stem detection and denoising
  • Stem segmentation
  • Forest inventory
  • Fast calculation of point features
  • Research basis and other applications
  • 3D plotting and manipulation

Installation from source

Requirements

  • devtools: run install.packages('devtools', dependencies = TRUE) from the R console
  • Rcpp compiler:
    • on Windows: install Rtools for your R version - make sure to add it to your system's path
    • on Mac: install Xcode
    • on Linux: be sure to have r-base-dev installed

Install TreeLS latest version

On the R console, run:

devtools::install_github('tiagodc/TreeLS')

Usage

Example of full processing workflow from reading a point cloud file until stem segmentation of a forest plot:

library(TreeLS)

# open sample plot file
file = system.file("extdata", "pine_plot.laz", package="TreeLS")
tls = readTLS(file)

# normalize the point cloud
tls = tlsNormalize(tls, keep_ground = F)
x = plot(tls)

# extract the tree map from a thinned point cloud
thin = tlsSample(tls, smp.voxelize(0.02))
map = treeMap(thin, map.hough(min_density = 0.1), 0)
add_treeMap(x, map, color='yellow', size=2)

# classify tree regions
tls = treePoints(tls, map, trp.crop())
add_treePoints(x, tls, size=4)
add_treeIDs(x, tls, cex = 2, col='yellow')

# classify stem points
tls = stemPoints(tls, stm.hough())
add_stemPoints(x, tls, color='red', size=8)

# make the plot's inventory
inv = tlsInventory(tls, d_method=shapeFit(shape='circle', algorithm = 'irls'))
add_tlsInventory(x, inv)

# extract stem measures
seg = stemSegmentation(tls, sgt.ransac.circle(n = 20))
add_stemSegments(x, seg, color='white', fast=T)

# plot everything once
tlsPlot(tls, map, inv, seg, fast=T)

# check out only one tree
tlsPlot(tls, inv, seg, tree_id = 11)

#------------------------------------------#
### overview of some new methods on v2.0 ###
#------------------------------------------#

file = system.file("extdata", "pine.laz", package="TreeLS")
tls = readTLS(file) %>% tlsNormalize()

# calculate some point metrics
tls = fastPointMetrics(tls, ptm.knn())
x = plot(tls, color='Verticality')

# get its stem points
tls = stemPoints(tls, stm.eigen.knn(voxel_spacing = .02))
add_stemPoints(x, tls, size=3, color='red')

# get dbh and height
dbh_algo = shapeFit(shape='cylinder', algorithm = 'bf', n=15, inliers=.95, z_dev=10)
inv = tlsInventory(tls, hp = .95, d_method = dbh_algo)
add_tlsInventory(x, inv)

# segment the stem usind 3D cylinders and getting their directions
seg = stemSegmentation(tls, sgt.irls.cylinder(n=300))
add_stemSegments(x, seg, color='blue')

# check out a specific tree segment
tlsPlot(seg, tls, segment = 3)

Copy Link

Version

Install

install.packages('TreeLS')

Monthly Downloads

29

Version

2.0.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 26th, 2020

Functions in TreeLS (2.0.2)

cylinderFit

Point cloud cylinder fit
sgt.ransac.circle

Stem segmentation algorithm: RANSAC circle fit
stm.hough

Stem denoising algorithm: Hough Transform
sgt.irls.cylinder

Stem segmentation algorithm: Iterated Reweighted Least Squares cylinder fit
stm.eigen.voxel

Stem denoising algorithm: Voxel eigen decomposition + point normals intersections voting
tlsCrop

Point cloud cropping
tlsInventory

Extract forest inventory metrics from a point cloud
ptm.knn

Point metrics algorithm: K Nearest Neighbors metrics
ptm.voxel

Point metrics algorithm: Voxel metrics
treeMap

Map tree occurrences from TLS data
tlsTransform

Simple operations on point cloud objects
readTLS

Import a point cloud file into a LAS object
sgt.irls.circle

Stem segmentation algorithm: Iterated Reweighted Least Squares circle fit
sgt.bf.cylinder

Stem segmentation algorithm: Brute Force cylinder fit
treePoints

Classify individual tree regions in a point cloud
trp.crop

Tree points algorithm: fixed size patches.
stemPoints

Stem points classification
smp.voxelize

Point sampling algorithm: systematic voxel grid
treeMap.merge

Merge tree coordinates too close on treeMap outputs.
trp.voronoi

Tree points algorithm: voronoi polygons.
writeTLS

Export TreeLS point clouds to las/laz files
setTLS

(Re-)Create a LAS object depending on the input's type
smp.randomize

Point sampling algorithm: random sample
tlsPlot

Plot TreeLS outputs
shapeFit.forks

EXPERIMENTAL: Point cloud multiple circle fit
tlsNormalize

Normalize a TLS point cloud
treeMap.positions

Convert a tree map to a 2D data.table
stemSegmentation

Stem segmentation
tlsRotate

Rotate point cloud to fit a horizontal ground plane
stm.eigen.knn

Stem denoising algorithm: KNN eigen decomposition + point normals intersections voting
sgt.ransac.cylinder

Stem segmentation algorithm: RANSAC cylinder fit
shapeFit

Point cloud cylinder/circle fit
tlsSample

Resample a point cloud
map.eigen.voxel

Tree mapping algorithm: Voxel geometry
gpsTimeFilter

Filter points based on the gpstime field
fastPointMetrics

Calculate point neighborhood metrics
map.eigen.knn

Tree mapping algorithm: KNN point geometry
circleFit

Point cloud circle fit
fastPointMetrics.available

Print available point metrics
map.hough

Tree mapping algorithm: Hough Transform
map.pick

Tree mapping algorithm: pick trees manually
nnFilter

Nearest neighborhood point filter