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
587 stars 132 forks source link

Error reading data with non-integer spectral attributes #659

Closed seanreilly66 closed 1 year ago

seanreilly66 commented 1 year ago

readLAS fails to load datasets that contain non-integer values for default spectral attributes. Returns the following error message:

Error: Invalid data: (Attribute name) is not an integer

Example:

library(lidR)

las <- LAS(data = data.frame(
  X = runif(100, 1, 10),
  Y = runif(100, 1, 10),
  Z = runif(100, 1, 10)
))

nir = runif(100)

las <- add_lasattribute(las, x = nir, name = 'nir', desc = 'nir')

f = tempfile(fileext = ".las")
writeLAS(las, f)
readLAS(f)
#> Attribute 'nir' renamed 'NIR' to match with default attribute names.
#> Erreur : Invalid data: NIR is not an integer

Discussed in https://github.com/r-lidar/lidR/discussions/658

Jean-Romain commented 1 year ago

Fixed thanks

Jean-Romain commented 1 year ago

I really enjoin you to use add_lasattribute_manual to store your nir as float instead of double