Skip to main content
1 of 4

How do I keep the unique segmented treeID when exporting the .las file into ArcPRO after using Rstudio running lidR tree segmentation

I want to export a .las file of segmented trees with the treeID column into ArcPro, but when I export the file the treeID column is not selectable and I really want the separate colours for the segmented trees.

I have tried changing the name of the treeID row in R and/or copying the data into a recognised header name in ArcPRO, I was trying to rename or copy the column "treeID" to "ReturnNumber" but I can not find a way that works and generally receive an error message similar to "no applicable method for 'rename' applied to an object of class "c('LAS', 'Spatial')".


library(lidR)
library(dplyr)

#  Import the las and segment the trees
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las <- readLAS(LASfile, select = "xyzr", filter = "-drop_z_below 0")
las1 <- segment_trees(las, li2012())
col <- random.colors(200)
plot(las1, color = "treeID", colorPalette = col)

#  trying to rename the columns like you can in a dataframe

select(las1, treeID=ReturnNumber)
# or
temp <- mutate(las1, UserData=ReturnNumber(las1))
#using the pipe function
las1 %>% 
  rename(treeID=ReturnNumber)

colnames(las1) 

#  write out .las to file for loading into ArcPRO
writeLAS(las = las1, file = "trees.las", index= TRUE)