# grid_tincanopy

##### Canopy height model based on a triangulation.

Canopy height model based on a triangulation of first returns. Depending on the inputs this function computes a simple Delaunay triangulation of the first returns with a linear interpolation within each triangle. This function also enables the use of the pit-free algorithm developed by Khosravipour et al. (2014), which is based on the computation of a set of classical triangulations at different heights (see reference).

##### Usage

```
grid_tincanopy(x, res = 0.5, thresholds = c(0, 2, 5, 10, 15),
max_edge = c(0, 1), subcircle = 0, filter = "-keep_first")
```

##### Arguments

- x
A LAS object

- res
numeric. Resolution of the canopy height model.

- thresholds
numeric. Set of height thresholds. If

`thresholds = 0`

the algorithm is a strict rasterization of the triangulation of the first returns. However, if an array is passed to the function it becomes the Khosravipour et al. pit-free algorithm.- max_edge
numeric. Maximum edge-length of a triangle in the Delaunay triangulation. If a triangle has an edge greater than this value it will be removed. It is used to drive the pit-free algorithm (see reference) and to trim dummy interpolation on non-convex areas. The first number is the value for the classical triangulation (threshold = 0), the second number is the value for the pit-free algorithm for (thresholds > 0). If

`max_edge = 0`

no trimming will be done.- subcircle
numeric. Radius of the circles. To obtain fewer pits the algorithm can replace each return with a circle composed of 8 points before computing the triangulation (see also grid_canopy).

- filter
character. Streaming filter while reading the files (see readLAS). If the input is a

`LAScatalog`

the function readLAS is called internally. The user cannot manipulate the lidar data directly but can use streaming filters instead.

##### Value

Returns a `data.table`

of class `lasmetrics`

, which enables easier
plotting and RasterLayer casting.

##### Use with a `LAScatalog`

When the parameter `x`

is a LAScatalog the function processes
the entire dataset in a continuous way using a multicore process. Parallel computing is set
by default to the number of core available in the computer. A buffer is required. The user
can modify the global options using the function catalog_options.
`lidR`

support .lax files. Computation speed will be *significantly* improved with a
spatial index.

##### References

Khosravipour, A., Skidmore, A. K., Isenburg, M., Wang, T., & Hussin, Y. A. (2014). Generating pit-free canopy height models from airborne lidar. Photogrammetric Engineering & Remote Sensing, 80(9), 863-872.

##### Examples

```
# NOT RUN {
LASfile = system.file("extdata", "Tree.laz", package="lidR")
las = readLAS(LASfile, Classification = FALSE, Intensity = FALSE, filter = "-drop_z_below 0")
# Basic triangulation and rasterization
chm1 = grid_tincanopy(las, thresholds = 0, max_edge = 0)
# Khosravipour et al. pitfree algorithm
chm2 = grid_tincanopy(las, thresholds = c(0,2,5,10,15), max_edge = c(0, 1.5))
plot(chm1)
plot(chm2)
# }
```

*Documentation reproduced from package lidR, version 1.3.0, License: GPL-3*