【问题标题】:Error in unique.default(x) : unique() applies only to vectors in rLiDAR packageunique.default(x) 中的错误:unique() 仅适用于 rLiDAR 包中的向量
【发布时间】:2020-06-09 00:06:54
【问题描述】:

我在使用 rLiDAR 中的 chullLiDAR2D 函数计算凸包时遇到此错误。有趣的是,在同一 LAS 文件上使用 chullLiDAR3D 计算 3D 凸包时,我没有收到此错误。我已经发布了代码和 XY_ID 变量以供进一步参考。

谢谢,

#Computing and plotting the 2D-convex hull of a LAS file
#Importing the LAS file
library(rLiDAR)
LAS_File <- system.file("test.las", package = "rLiDAR")
#Read the LAS file
LAS <- readLAS("D:/Summer_2019/NRS_Project/01_data/01_las_2013/test.las", short = TRUE)
#Subsetting the height of the data
XYZ <- subset(LAS[,1:3],LAS[,3] >= 1.37)
#Get the LiDAR clusters
set.seed(1)
clLAS <- kmeans(XYZ, 32)
#Setting the IDs of the points
ID <- as.factor(clLAS$cluster)
#Setting the XYZID input
XY_ID <- cbind(XYZ[,1:2],ID)
summary(XY_ID)
View(XY_ID)
#Calculating the LiDAR convex hull of the clusters
chull_Trees <- chullLiDAR2D(XY_ID)

XY_ID

【问题讨论】:

    标签: r lidar lidar-data


    【解决方案1】:

    ID 向量必须命名为“id”

    这在chullLiDAR2D的帮助页面中有一些记录:

    参数

    xyid    
    A 3-column matrix with the x, y coordinates and points id of the LiDAR point cloud.
    

    查看函数本身,“id”是硬编码的。

    # chullLiDAR2D #
    function (xyid) 
    {
        spdfList <- plyr::dlply(as.data.frame(xyid), "id", 
            function(input) { ...
    

    所以,只需将名称从 ID 更改为 id,一切都会好起来的。

    #Setting the IDs of the points
    id <- as.factor(clLAS$cluster)
    
    #Setting the XYZID input
    XY_ID <- cbind(XYZ[,1:2], id)
    
    #Calculating the LiDAR convex hull of the clusters
    chull_Trees <- chullLiDAR2D(XY_ID)
    
    # Plotting the LiDAR convex hull
    library(sp)
    plot(SpatialPoints(xyid[,1:2]),cex=0.5,col=xyid[,3])
    plot(chullTrees$chullPolygon, add=TRUE, border='black')
    

    【讨论】:

    • 附带说明,我可以将绘图导出为 .asc 文件或任何光栅格式吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-12
    • 1970-01-01
    相关资源
    最近更新 更多