-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error assignment of an object of class “logical” is not valid using readLAS in 3.2.0 #485
Comments
I need the file to reproduce |
Here you go. Thanks for the quick response JR. |
It is perfectly read on my machine library(lidR)
readLAS("lidarAOI.las")
#> class : LAS (v1.3 format 3)
#> memory : 37.2 Mb
#> extent : 320643.5, 321000, 4096591, 4097000 (xmin, xmax, ymin, ymax)
#> coord. ref. : WGS 84 / UTM zone 11N
#> area : 87275.38 m²
#> points : 424.1 thousand points
#> density : 4.86 points/m² Which version of |
R and package infor version: 4.1.1 readLASheader output
Operating system informationWindows 10 home |
Tested on windows and everything was ok. I suggest to reinstall lidR. |
It seems the issue was that I had conflicting packages (and/or global settings) from my old Rstudio and R install. A complete uninstall of R, Rstudio, and Rtools, as well as removing temporary files and folders in the users directory, should fix the issue. |
I have the exact same issue both on Mac and windows
|
it is not working after reinstalling R, Rstudio and Rtools on windows 10 lidar<-readLAS("C:/Users/..../Downloads/Kompia_Cloud_P2_buffer_10m.laz")
#> Error in (function (cl, name, valueClass) :
#> assignment of an object of class “logical” is not valid for @‘proj4string’ in an object of class “LAS”; is(value, "CRS") is not TRUE
#> In addition: Warning messages:
#> 1: Invalid data: 27 points with a return number equal to 0 found.
#> 2: Invalid data: 27 points with a number of returns equal to 0 found. |
Follow this link for a complete uninstall (on windows): Quick review from that link: Also make sure to remove the directories for R and Rstudio in this directory: If you don't remove those directories after uninstall, the previous dependencies are still saved. So make sure to do so. After everything is uninstalled and you cleared those directories, then go ahead and reinstall in this order:
After you reinstalled, start by installing lidR through Rstudio, which will download all the necessary packages. Then test by reading in a lidar file.
|
I follow that procedure twice make sure and, yet, does not work for me: Error in (function (cl, name, valueClass) : |
and it gives the very same error on both MAC and windows after reinstalling R, Studio and Rtools (and cleaning the related files carefully) rror in (function (cl, name, valueClass) : |
I have the same error. Followed @arojas314 suggestion but the problem persists. LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
ctg = readLAScatalog(LASfile)
#> Error in sp::SpatialPolygons(pgeom, proj4string = crs) :
#> is(proj4string, "CRS") is not TRUE |
Check that GDAL or PROJ is already installed on your system, and if so, remove the paths from your environment variables. |
@Jean-Romain, will do. But what is exactly the source of the issue? I just test "lidR 3.1.4" in my personal MAC and it works perfectly as opposed to my work MAC with "lidR 3.2.1". Is there any work around for that using "lidR 3.2.1"? for instance by using rlas to read the .las file : p = rlas::read.las("hen_faes_plot3_lidar.laz", filter = "-keep_random_fraction 0.01")
h = rlas::read.lasheader("hen_faes_plot3_lidar.laz") and do some additional procedure to get around the error and build the lidar file in rlas by bringing together p and h ? |
I am starting a new issue because you are exactly right, we tested 3.2.1 across multiple windows and mac machines to no avail. We all get the same error. But when we installed the 3.1.4 version, it works fine. To install lidR 3.1.4:
|
Ok I think I know what might be the problem. The only difference that might explain your trouble is the fact that 3.2.0 no longer uses
|
|
note that I'm reporting you results from my MAC, not Windows (I can do it later if necessary) 1- I've tried a few files and get the error message for all of them (see below readLASheader(file.las) for two examples) 2- sf package version (me 1.0-3) 3-
1a)
1b)
|
Ok good! Not really actually but thank you anyway. Please show me LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header = readLASheader(LASfile)
crs(header)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs |
Funny: LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header = readLASheader(LASfile)
crs(header)
#> [1] NA |
Could you show the message after you load lidR using library(lidR)? |
that's another funny one. I've been receiving different messages lately, but here's the message since this problem started: require(lidR)
Loading required package: lidR
Loading required package: raster
Loading required package: sp
lidR 3.2.1 using 1 threads. Help on <gis.stackexchange.com>. Bug report on <github.com/Jean-Romain/lidR>.
Warning message:
multiple methods tables found for ‘area’ |
I receive the same message when loading lidR version 3.2.1, but not when loading the 3.1.4
|
Good we caught it, we got epsg = epsg(header)
epsg
#> [1] 26917
lidR:::epsg2CRS(epsg)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
crs = sf::st_crs(paste0("EPSG:", epsg))
crs
#> PROJCRS["NAD83 / UTM zone 17N" [...]
as(crs, "CRS")
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs |
|
Well, I do not understand. You ran, reprex::reprex({
library(lidR)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header = readLASheader(LASfile)
crs(header)
projection(header)
projection(header, FALSE)
epsg = epsg(header)
epsg
lidR:::epsg2CRS(epsg)
lidR:::epsg2CRS(epsg, TRUE)
crs = sf::st_crs(paste0("EPSG:", epsg))
crs$Name
as(crs, "CRS")
}) |
Ok guys I reproduced on Windows. I don't know why it worked last time, I updated few thing and now it does not work. I will be able to fix it. It looks like a clash in namespace. Very weird. Windowslibrary(lidR)
#> Le chargement a nécessité le package : raster
#> Le chargement a nécessité le package : sp
#> Warning: tables de méthodes multiples trouvées pour 'area'
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header = readLASheader(LASfile)
crs(header)
#> [1] NA
projection(header)
#> [1] "+proj=utm +zone=17 +datum=NAD83 +units=m +no_defs"
projection(header, FALSE)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
epsg = epsg(header)
lidR:::epsg2CRS(epsg)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
lidR:::epsg2CRS(epsg, TRUE)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
crs = sf::st_crs(paste0("EPSG:", epsg))
crs$Name
#> [1] "NAD83 / UTM zone 17N"
as(crs, "CRS")
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
readLAS(LASfile)
#> Error in (function (cl, name, valueClass) : assignment of an object of class "logical" is not valid for @'proj4string' in an object of class "LAS"; is(value, "CRS") is not TRUE Linuxlibrary(lidR)
#> Le chargement a nécessité le package : raster
#> Le chargement a nécessité le package : sp
library(terra)
#> terra version 1.4.11
#>
#> Attachement du package : 'terra'
#> Les objets suivants sont masqués depuis 'package:lidR':
#>
#> area, crs, crs<-
#> Les objets suivants sont masqués depuis 'package:raster':
#>
#> adjacent, animate, area, boundaries, buffer, cellFromRowCol,
#> cellFromRowColCombine, cellFromXY, clamp, click, colFromCell,
#> colFromX, cover, crop, crosstab, crs, crs<-, distance, erase,
#> extend, extract, flip, focal, freq, geom, hasValues, init,
#> inMemory, interpolate, mask, modal, mosaic, ncell, ncol<-, nrow<-,
#> origin, origin<-, plotRGB, rasterize, readStart, readStop, rectify,
#> res, res<-, resample, RGB, rotate, rowColFromCell, rowFromCell,
#> rowFromY, setMinMax, setValues, shift, stretch, symdif, terrain,
#> trim, values, values<-, writeRaster, writeStart, writeStop,
#> writeValues, xFromCell, xFromCol, xmax, xmax<-, xmin, xmin<-, xres,
#> xyFromCell, yFromCell, yFromRow, ymax, ymax<-, ymin, ymin<-, yres,
#> zonal, zoom
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header = readLASheader(LASfile)
crs(header)
#> Error in (function (classes, fdef, mtable) : unable to find an inherited method for function 'crs' for signature '"LASheader"'
projection(header)
#> [1] "+proj=utm +zone=17 +datum=NAD83 +units=m +no_defs"
projection(header, FALSE)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
epsg = epsg(header)
lidR:::epsg2CRS(epsg)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
lidR:::epsg2CRS(epsg, TRUE)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
crs = sf::st_crs(paste0("EPSG:", epsg))
crs$Name
#> [1] "NAD83 / UTM zone 17N"
as(crs, "CRS")
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
readLAS(LASfile)
#> class : LAS (v1.2 format 1)
#> memory : 6.2 Mb
#> extent : 684766.4, 684993.3, 5017773, 5018007 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83 / UTM zone 17N
#> area : 53112.69 m²
#> points : 81.6 thousand points
#> density : 1.54 points/m² Created on 2021-10-15 by the reprex package (v2.0.1) |
I do not understand the problem, I changed a single line of code to bypass the error and every problems are gone including some that look completely unrelated... It does not make sense...
Please install 3.2.2 and tell me if it is fixed on your machine. Do not ask me what was the problem remotes::install_github("Jean-Romain/lidR") Windowslibrary(lidR)
#> Le chargement a nécessité le package : raster
#> Le chargement a nécessité le package : sp
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header = readLASheader(LASfile)
crs(header)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
projection(header)
#> [1] "+proj=utm +zone=17 +datum=NAD83 +units=m +no_defs"
projection(header, FALSE)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
epsg = epsg(header)
lidR:::epsg2CRS(epsg)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
lidR:::epsg2CRS(epsg, TRUE)
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
crs = sf::st_crs(paste0("EPSG:", epsg))
crs$Name
#> [1] "NAD83 / UTM zone 17N"
as(crs, "CRS")
#> CRS arguments:
#> +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
readLAS(LASfile)
#> class : LAS (v1.2 format 1)
#> memory : 6.2 Mb
#> extent : 684766.4, 684993.3, 5017773, 5018007 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83 / UTM zone 17N
#> area : 53112.69 m²
#> points : 81.6 thousand points
#> density : 1.54 points/m² Created on 2021-10-15 by the reprex package (v2.0.1) |
Considering that on my Windows machine 3.2.1 was binary by the CRAN and 3.2.2 is self compiled my best guess is an issue with CRAN binaries. You will test it and I will submit the fix to CRAN if it works for you. We will retry with CRAN binaries when they will be available. |
I confirm it is not an issue with lidR 3.2.1 but with CRAN binaries remotes::install_github("cran/lidR") # works
install.packages("lidR") # fails
install.packages("lidR", type="source") # works I"ll release 3.2.2 with hope it will fix it by triggering a new build |
After installing lidR using remotes::install_github("cran/lidR") ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
|
This is an issue with your compiler. Can't help on Mac |
I got the same message. Error in (function (cl, name, valueClass) : |
I made some tests this morning before to release 3.2.2 and version 3.2.1 from CRAN worked fine. The version 3.2.1 on CRAN for Windows R-release is a build from friday October 15th i.e. few hours only after my last test. It seems that the new binaries are not corrupted. Please try again on windows and confirm if it works. On Mac OS however the build is still from October 5th. I do not know yet if I'm releasing 3.2.2 to trigger a new build. I'm waiting for your feedback |
I followed this message and re-installed 3.2.1 with "install.packages("lidR", type="source")" .
It has been working just fine. No errors so far reading any LAS or LAZ file. |
See my message above. Can you try again |
Thanks. Its working perfectly now. After installation the version is still 3.2.1 though. Thanks again. |
Because I did nothing. The CRAN rebuild the package friday after my last message (no causality at all, just random luck). The new binaries seem not being corrupted |
I released 3.2.2. I hope this will fix the problem. Binaries should be available within a week |
MacOS releases are available. Please confirm it works |
Hi @Jean-Romain , it works on both MacOS and Windows 10. Thank you so much for your promptly and helpfull response. |
Hi, @Jean-Romain, when I run readLas in a loop, it causes a fatal error and aborts the program. Is there a way to avoid this? for(fileName in NEONpoints2017){
#Bring point cloud into Rstudio
NEONpoints <- readLAS(fileName)
#Calculate vegetation height above the ground
NEON_DSM = normalize_height(NEONpoints, algorithm = knnidw(k = 12, p = 3), na.rm = TRUE)
#Remove points that are below 0
NEON_DSM_clean = filter_poi(NEON_DSM, Z < 45)
#plot(NEON_DSM_clean)
#Create canopy height model(raster) from the normalized canopy points
NEON_CHM = grid_canopy(NEON_DSM_clean, res = 0.5, p2r(subcircle = 0.3, na.fill = NULL))
#Export the Canopy Height Model to a .tif
writeRaster(NEON_CHM,
filename=paste("D:/projects/RaBET/NEON_ONAQ/NEON_lidar-point-cloud-line/",substr(fileName, 43, 55), "_2017_CHM"),
format="GTiff",
overwrite=TRUE)
} |
Your question is not related to the content of this issue. Please open an issue with a reproducible example |
Hi, is this available in Portugal? I've been trying to find it at packages library but the only available version is lidR 3.2.1.
|
Hello,
I have an issue where i am trying to read a .LAS file using
readLAS()
function, but I am receiving an error. I am using a windows x64 machine.My code:
Error message:
Thanks,
Alex
The text was updated successfully, but these errors were encountered: