chullLiDAR3D {rLiDAR} | R Documentation |
Compute and plot the 3D convex hull (and its surface area and volume) of the individual tree LiDAR-derived point cloud.
chullLiDAR3D(xyzid,plotit=TRUE,col="forestgreen",alpha=0.8)
xyzid |
A matrix with four columns (xyz coordinates and tree id). |
plotit |
Logical. If FALSE, returns only volume and surface area. |
col |
A vector or a caracter of the convex hull color. |
alpha |
A vector or a caracter of the convex hull transparency (0-1). |
A list with components 'crownvolume' and 'crownsurface', giving the volume and surface of the convex hull.
Carlos Alberto Silva. Uses code by Remko Duursma (YplantQMC package,see "crownhull").
www.qhull.org and geometry package (see convhulln
).
# Importing LAS file: LASfile <- system.file("extdata", "LASexample1.las", package="rLiDAR") # Reading LAS file LAS<-readLAS(LASfile,short=TRUE) # Setring the xyz coordinates and subsetting the data xyz<-subset(LAS[,1:3],LAS[,3] >= 1.37) # Finding clusters clLAS<-kmeans(xyz, 32) # Set the id vector id<-as.factor(clLAS$cluster) #=================================================# # Example 01 #=================================================# # Set the alpha alpha<-0.6 # Set the plotCAS parameter plotit=TRUE # Set the convex hull color col="forestgreen" # Combining xyz and id xyzid<-cbind(xyz,id) # Get the volume and surface area library(rgl) open3d() volumeList<-chullLiDAR3D(xyzid=xyzid, plotit=plotit, col=col,alpha=alpha) summary(volumeList) # summary plot3d(xyzid[,1:3], add=TRUE) # add the 3D point cloud axes3d(c("x+", "y-", "z-")) # axes grid3d(side=c('x+', 'y-', 'z'), col="gray") # grid title3d(xlab = "UTM Easthing", ylab = "UTM Northing",zlab = "Height", col="red") aspect3d(1,1,0.7) # scale #=================================================# # Example 02 #=================================================# # Set the alpha alpha<-0.85 # Set the plotCAS parameter plotit=TRUE # Set the convex hull color col=levels(factor(id)) # Combining xyz and id xyzid<-cbind(xyz,id) # Get the volume and surface area open3d() volumeList<-chullLiDAR3D(xyzid=xyzid, plotit=plotit, col=col,alpha=alpha) summary(volumeList) # Add other plot parameters plot3d(xyzid[,1:3], col=xyzid[,4], add=TRUE) # add the 3D point cloud axes3d(c("x+", "y-", "z-")) # axes grid3d(side=c('x+', 'y-', 'z'), col="gray") # grid title3d(xlab = "UTM Easthing", ylab = "UTM Northing",zlab = "Height", col="red") aspect3d(1,1,0.7) # scale