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
601 stars 131 forks source link

No attribute 'Zref' found. Un-normalizisation is impossible. #530

Closed flottsam closed 2 years ago

flottsam commented 2 years ago

I just tried to unnormalize_height(las), but received the error:

No attribute 'Zref' found. Un-normalizisation is impossible.

I've not had this problem in the past. It appears that the Zref attribute is indeed missing in the normalized las file.

Jean-Romain commented 2 years ago

Please provide a minimal reproducible example. Did you normalize with normalize_height()?

candelas762 commented 2 years ago

Hi. This seems to be closed but I have the same problem. I am using some normalized clouds generated some years ago in LP360 and were stored in txt format. I used txt2las to convert them to LAS but when I try to unnormalize them it gives the error mentioned above. The clouds are classified into ground and no-ground. Is it possible to add this "Zref" attribute? Also, it might be worthy to mention that I have access to data of the same sites to create a DTM.

candelas762 commented 2 years ago

HI. I came up with this workaround:

library(lidR)
library(terra)
library(sf)

dtm = terra::rast("path_to_dtm")
las = readLAS("path_to_las_file")
points <- st_as_sf(x = data.frame(las$X, las$Y), 
                        coords = c("las.X", "las.Y"),
                        crs = st_crs(25832))
Zdtm <- terra::extract(dtm, terra::vect(points))
las_unn = las
las_unn$Z = las_unn$Z + Zdtm[,2]