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
614 stars 134 forks source link

Error: no applicable method for 'readLAS' applied to an object of class "LAS" #777

Closed leonard-leo closed 2 months ago

leonard-leo commented 2 months ago

Hello,

I got the error below after running this code chunk:

sample <- lidR::readLAS(file.path("sample.las") voxels_lad <- leafR::lad.voxels(sample, grain.size = 2, k = 1)

Error in UseMethod("readLAS", files) : no applicable method for 'readLAS' applied to an object of class "LAS"

The sample.las file is properly loaded using the readLAS function, so I honestly have no idea why I'm getting that error.... Any ideas? I'm using a Macbook Pro M1, R version 4.4.1, and latest versions of the lidR and leafR packages.

Thank you! Leonardos

Jean-Romain commented 2 months ago

This is an error with the leafR package. I'm not the author of leafR. My guess is that las.voxels is expecting the path to the file and loads it on the fly with readLAS() internally. Check the documentation.

leonard-leo commented 2 months ago

Hi Jean-Romain,

You're right, it worked after specifying the complete path to the file. Thanks!