r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
612 stars 133 forks source link

Character palette causes error #726

Closed dmurdoch closed 1 year ago

dmurdoch commented 1 year ago

This line: https://github.com/r-lidar/lidR/blob/dd16f690565a370e30eb369ad5c0bee11f8f81fb/R/plot.R#L290C35-L290C35 causes an error if the palette is specified as a vector of colors.

A simple fix is to change it to

  autocol <- is.character(pal) && length(pal) == 1 && pal == "auto"

Here is code to illustrate:

 LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
 las <- readLAS(LASfile)
 lidR::plot(las,size=5,pal=grDevices::terrain.colors(30),axis=TRUE)

This was reported here.