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
582 stars 130 forks source link

Character palette causes error #726

Closed dmurdoch closed 9 months ago

dmurdoch commented 9 months 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.