Create cubes of a given distance in a point cloud though their voxelization. It use a modify version of the code used in Greaves et al. 2015.

voxels(cloud, edge_length, threads = 1L, obj.voxels = TRUE)

Arguments

cloud

A data.table with *XYZ* coordinates in the first three columns.

edge_length

A positive numeric vector with the voxel-edge length for the x, y, and z coordinates. It use the same dimensional scale of the point cloud.

threads

An integer specifying the number of threads to use for parallel processing. Experiment to see what works best for your data on your hardware.

obj.voxels

Logical. If obj.voxel = TRUE, it returns an object of class "voxels", If obj.voxel = FALSE, it returns a data.table with the coordinates of the voxels created and the number of points in each voxel. TRUE as default.

Value

If obj.voxels == TRUE, it return an object of class "voxels" which contain a list with the points used to create the voxels, the parameter edge_length, and the voxels created. If FALSE, it returns a data.table with the coordinates of the voxels created and the number of points in each voxel.

Details

Voxels are created from the negative to the positive *XYZ* coordinates.

References

Greaves, H. E., Vierling, L. A., Eitel, J. U., Boelman, N. T., Magney, T. S., Prager, C. M., & Griffin, K. L. (2015). Estimating aboveground biomass and leaf area of low-stature Arctic shrubs with terrestrial LiDAR. Remote Sensing of Environment, 164, 26-35.

Author

J. Antonio Guzmán Q.

Examples

data("pc_tree")

###Create cube of a size of 0.5.
voxels(pc_tree, edge_length = c(0.5, 0.5, 0.5))
#> $cloud
#>               X        Y          Z
#>     1:  9.14850 -1.11025 0.00099992
#>     2:  9.22250 -1.12225 0.00000000
#>     3:  9.12125 -1.09025 0.03899991
#>     4:  9.14725 -1.15775 0.10199999
#>     5:  9.14675 -1.10650 0.08574998
#>    ---                             
#> 75844: 11.43875  1.20600 5.42024994
#> 75845: 11.46825  1.19425 5.46449995
#> 75846: 11.39125  1.27450 5.39824963
#> 75847: 11.34125  1.23475 5.42525005
#> 75848: 11.38000  1.25925 5.45124960
#> 
#> $parameter
#> X.size Y.size Z.size 
#>    0.5    0.5    0.5 
#> 
#> $voxels
#>             X          Y    Z  N
#>   1:  9.38575 -1.2837501 0.25 37
#>   2:  8.88575 -1.2837501 0.25 12
#>   3:  8.88575 -0.7837501 0.25 36
#>   4:  9.38575 -1.2837501 0.75 47
#>   5:  8.88575 -1.2837501 0.75  8
#>  ---                            
#> 675: 10.38575  2.2162499 5.25  3
#> 676: 10.88575  1.7162499 5.25 95
#> 677: 11.38575  1.7162499 5.25  2
#> 678: 10.88575  2.2162499 5.25 17
#> 679: 10.88575  2.7162499 4.75  8
#> 
#> attr(,"class")
#> [1] "voxels"