segment_trees: Individual tree segmentation

Description Usage Arguments Value Uniqueness Working with a LAScatalog Supported processing options Examples

View source: R/segment_trees.R

Description

Individual tree segmentation with several possible algorithms. The returned point cloud has a new extra byte attribute named after the parameter attribute independently of the algorithm used.

Usage

1
segment_trees(las, algorithm, attribute = "treeID", uniqueness = "incremental")

Arguments

las

An object of class LAS or LAScatalog.

algorithm

function. An algorithm of individual tree segmentation. lidR has: dalponte2016, watershed, li2012 and silva2016. More experimental algorithms may be found in the package lidRplugins.

attribute

character. The returned LAS object as a new extra byte attribute (in a new column). This parameter controls the name of the new attribute. Default is "treeID".

uniqueness

character. A method to compute a unique ID. Can be 'incremental', 'gpstime' or 'bitmerge'. See section 'Uniqueness'. This feature must be considered as 'experimental'.

Value

If the input is a LAS object, return a LAS object. If the input is a LAScatalog, returns a LAScatalog.

Uniqueness

By default the tree IDs are numbered from 1 to n, n being the number of trees found. The problem with such incremental numbering is that, while it ensures a unique ID is assigned for each tree in a given point-cloud, it also guarantees duplication of tree IDs in different tiles or chunks when processing a LAScatalog. This is because each file is processed independently of the others and potentially in parallel on different computers. Thus, the index always restarts at 1 on each file or chunk. Worse, in a tree segmentation process, a tree that is located exactly between 2 files will have two different IDs for its two halves.

This is why we introduced some uniqueness strategies that are all imperfect and that should be seen as experimental. Please report any troubleshooting. Using a uniqueness-safe strategy ensures that trees from different files will not share the same IDs. Moreover, it also means that two halves of a tree on the edge of a processing chunk will be assigned the same ID.

incremental

Number from 0 to n. This method does not ensure uniqueness of the IDs. This is the legacy method.

gpstime

This method uses the gpstime of the highest point of a tree (apex) to create a unique ID. This ID is not an integer but a 64-bit decimal number which is suboptimal but at least it is exepected to be unique if the gpstime attribute is consistent across files. If inconsistencies with gpstime are reported (for example gpstime records the week time and was reset to 0 in a coverage that takes more than a week to complete), there is a (low) probability to get ID attribution errors.

bitmerge

This method uses the XY coordinates of the highest point (apex) of a tree to create a single number with a bitwise operation. First, XY coordinates are converted to integers using the scales and offsets of the point-cloud. Then the ID is computed with X * 2^32 + Y to combine twice the 32-bits of information into a 64-bit number. For example, if the apex is at (10.32, 25.64) with a scale factor of 0.01 and an offset of 0, the integer coordinates are X = 1032 and Y = 2564 and the ID is 4432406252036. Such methods return a 64-bit integer but because 64-bit integers do not exist in R it is converted to a 64-bit decimal number that is guaranteed to be unique if all files have the same offsets and scale factors.

All the proposed options are suboptimal because they either do not guarantee uniqueness in all cases (inconsistencies in the collection of files), or they imply that IDs are based on non-integers or meaningless numbers. But at the very least we expect this to work for simple cases.

Working with a LAScatalog

This section appears in each function that supports a LAScatalog as input.

In lidR when the input of a function is a LAScatalog the function uses the LAScatalog processing engine. The user can modify the engine options using the available options. A careful reading of the engine documentation is recommended before processing LAScatalogs. Each lidR function should come with a section that documents the supported engine options.

The LAScatalog engine supports .lax files that significantly improve the computation speed of spatial queries using a spatial index. Users should really take advantage a .lax files, but this is not mandatory.

Supported processing options

Supported processing options for a LAScatalog (in bold). For more details see the LAScatalog engine documentation:

Examples

1
2
3
4
5
6
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las <- readLAS(LASfile, select = "xyz", filter = "-drop_z_below 0")

# Using Li et al. (2012)
las <- segment_trees(las, li2012(R = 3, speed_up = 5))
plot(las, color = "treeID")

lidR documentation built on June 21, 2021, 5:07 p.m.