tiagodc / TreeLS

R functions for processing individual tree TLS point clouds
GNU General Public License v3.0
82 stars 27 forks source link

Errors with treeMap() when not using map.hough() #20

Closed jdonager closed 4 years ago

jdonager commented 4 years ago

Hello again! In the development version, I am unable to use either of the eigen methods within treeMap().

So with code: las <- readLAS(lazs[i]) map <- treeMap(las, method = map.eigen.knn())

I receive this error: point cloud apparently not normalized Calculating knn fastPointMetrics Error in knn(las %>% las2xyz, k = n + 1) : Requesting more points (101) than available in cloud (19)

**The las is indeed normalized, I continue to receive that warning.

With this code: las <- readLAS(lazs[i]) map <- treeMap(las, method = map.eigen.voxel()) point cloud apparently not normalized Calculating voxel fastPointMetrics Error in knn(nxy[, -1], k = 2) : Cloud has no points In addition: Warning messages: 1: In max(Z) : no non-missing arguments to max; returning -Inf 2: In min(Z) : no non-missing arguments to min; returning Inf

** The las object certainly has points: las <- readLAS(lazs[i]) las class : LAS (v1.3 format 3) memory : 7.8 Mb extent : 431791.4, 431816.7, 3899186, 3899208 (xmin, xmax, ymin, ymax) coord. ref. : +proj=utm +zone=12 +datum=WGS84 +units=m +no_defs area : 391.0242 m² points : 75.2 thousand points density : 192.31 points/m²

With the map.hough() method, it works fine, albeit with the same warning about normalization: las <- readLAS(lazs[i]) map <- treeMap(las, map.hough()) point cloud apparently not normalized map class : LAS (v1.2 format 0) memory : 2.4 Mb extent : 431791.2, 431810.7, 3899194, 3899207 (xmin, xmax, ymin, ymax) coord. ref. : NA area : 52.53136 units² points : 45 thousand points density : 857.05 points/units²

I have confirmed that this is consistent with several TLS point clouds. I can share the point cloud if needed. Thanks again for your work, Jonathon

tiagodc commented 4 years ago

If you can share one of those point clouds it will be very helpful. Thanks.

tiagodc commented 4 years ago

My hunch is that the error is in the treeMap.merge method used internally. Try to run treeMap(las, method = map.eigen.knn(), merge=0) and see if it works, meanwhile I'll check this bug. Thanks for reporting again!

jdonager commented 4 years ago

https://drive.google.com/file/d/1FmYp2Fz-TvYosZJsgwvQFkmgE_Xxi_ZN/view?usp=sharing https://drive.google.com/file/d/1YrC1fDbAwfJ3UOzQ9g2kvd7p9v3F5cnU/view?usp=sharing Two laz files of the same area, which both produced the same error for me.

jdonager commented 4 years ago

when I try treeMap() with merge=0 I am still getting the same errors.

tiagodc commented 4 years ago

Fixed.

Turns out your point clouds were not very dense and those methods apply a few heavy thinnings in the point density. Those thinnings were based on either fixed parameters or user inputs. Those parameters were originally set considering that TLS point clouds are usually very dense (thousands of points / m²), and I haven't considered their application on less dense clouds, like UAV scans.

I reconsidered those assumptions and altered the code to "guess" those parameters based on the point cloud density itself, so they're now more automatic but still require close attention from the user to try out and set the best parameters for each use case.

Please keep reporting :)

jdonager commented 4 years ago

Hi, I just reinstalled, but am getting the exact same errors as before.

jdonager commented 4 years ago

The point clouds were subsampled previous to running the analyses.

jdonager commented 4 years ago

I have also changed parameters within the method call, but still get the same error.

tiagodc commented 4 years ago

strange... I even added extra error handlers. What OS are you working on? Can you confirm that your TreeLS version is v2.0.2?

jdonager commented 4 years ago

I am on Linux Ubuntu 20.04, and yes, the version installed is 2.0.2

tiagodc commented 4 years ago

Can you share the exact code snippet and which dataset?

tiagodc commented 4 years ago

Can you share the exact code snippet and which dataset?

jdonager commented 4 years ago

Ah, my mistake! It looks like when I installed the new version, I must have failed to call the new library. Restarting R fixed the problem and it is working now as you indicated. My apologies!