Movatterモバイル変換


[0]ホーム

URL:


lacunr

License: GPL v3R-CMD-check

lacunr is an R package for calculating 3D lacunarityfrom voxel data. It is designed to be used with LiDAR point clouds tomeasure the heterogeneity or “gappiness” of 3-dimensional structuressuch as forest stands. It provides fast C++ functions to efficientlyconvert point cloud data to voxels and calculate lacunarity usingdifferent variants of Allain & Cloitre’s well-known gliding-boxalgorithm.

Installation

You can installlacunr from CRAN with:

install.packages("lacunr")

Or you can install the development version oflacunrfromGitHub with:

# install.packages("devtools")devtools::install_github("ElliottSmeds/lacunr")

Basic Usage

The standard workflow forlacunr is fairly simple:

  1. Convert point cloud data to voxels usingvoxelize()
  2. Arrange the voxels into a 3-dimensional binary map usingbounding_box()
  3. Calculate a lacunarity curve usinglacunarity()
library(lacunr)# create a data.frame of simulated point cloud datapc<-data.frame(X =rnorm(1000,10),Y =rnorm(1000,50),Z =rnorm(1000,25))# convert to voxels of size 0.5vox<-voxelize(pc,edge_length =c(0.5,0.5,0.5))# generate binary mapbox<-bounding_box(vox)# calculate lacunarity curvelac_curve<-lacunarity(box)

Interfacing withlidR

Thelidrpackage offers a robust suite of tools for processing LiDAR data.Whilelacunr does not requirelidR as adependency, it is assumed that most users will be working with pointcloud data imported usinglidR, and the package is designedto mesh well withlidR’s data objects. The following tipswill help make combining these packages as seamless as possible.

Working withLASobjects

Users should take special care when using alidRLAS object as input for thevoxelize()function. SinceLAS is an S4 class, it is important toextract the point cloud data from theLAS object using@data, otherwisevoxelize() will throw anerror:

library(lidR)# read in LAS point cloud filelas<-readLAS("<file.las>")# voxelize the LAS point cloud, taking care to input the correct S4 slotvox<-voxelize(las@data,edge_length =c(0.5,0.5,0.5))

Voxelization usinglidR

lidR offers its own extremely versatile voxelizationfunction,voxel_metrics().This provides a useful alternative tovoxelize(), althoughit is important to note that both functions utilize different algorithmsand will not produce identical results (see the following section formore details).

voxel_metrics() returns alasmetrics3dobject.lacunr’sbounding_box() function canaccept this as an input, but it also requires that it contain a columnnamedN, recording the number of points in each voxel. Thiscolumn can be generated byvoxel_metrics() using thefollowing:

# read in LAS point cloud filelas<-readLAS("<file.las>")# voxelize at 1m resolution, creating a column N containing the number of pointsvox<-voxel_metrics(las,~list(N =length(Z)),res =1)# convert to arraybox<-bounding_box(vox)

Details onvoxelize() vslidR::voxel_metrics()

voxelize() is adapted from the functionvoxels(), originally written by J. Antonio Guzmán Q. forthe packagerTLS. It isintended as a complement rather than a replacement forlidR’s more elaboratevoxel_metrics(). Eachfunction has a different underlying algorithm and will produce distinctresults from the same input data. The chief advantages ofvoxelize() overvoxel_metrics() are:

  1. It allows – and in fact requires – the user to specify all threedimensions of the desired voxel resolution independently. This makes itpossible to completely customize the shape of the voxels, in the rareinstance that one wishes to divide up a point cloud into a non-cubicvoxel grid.voxel_metrics() permits at most twodimensions.
  2. The point cloud can be divided into an even number of voxel bins.For example, if you have a point cloud that spans 12 meters in the Xdimension, and voxelize it at a resolution of 1 meter, the resultingdata will be binned into 12 1-meter voxels along the X axis. The samepoint cloud will be binned into 13 voxels byvoxel_metrics(). This is due to differences in how eachfunction aligns the point cloud data within the voxel grid.

[8]ページ先頭

©2009-2025 Movatter.jp