tiagodc / TreeLS

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

Error: Cloud has no points in treeMap #26

Closed mansi-aggarwal-2504 closed 3 years ago

mansi-aggarwal-2504 commented 3 years ago

Hello! I have been using the latest version of TreeLS with hough transformation method for treeMap and stemPoints, and smp.voxelize for tlsSample. I have had no problem so far, but today, for a certain file, I have been getting this error in treeMap: Error in knn(nxy[__COMMA__ -1]__COMMA__ k = 2): Cloud has no points

Even at different values of min_h and max_h. The point density is decent and trees are visible in plot but I don't understand the reason behind this error. Can someone help?

tiagodc commented 3 years ago

That's a new one... can you share the data (or a small sample) with the exact code you used on it and got the error? Thanks

mansi-aggarwal-2504 commented 3 years ago

Thank you for your reply @tiagodc. Please find the file and a snippet of the code here. Let me know if this works. Thanks!

tiagodc commented 3 years ago

@mansi-aggarwal-2504 , your data is apparently from ALS, maybe an UAV flight, right? It's density is quite low in comparison to TLS point clouds so the parameters of the map.hough algorithm need some extra tweaking to fit your use case. By changing just a couple parameters from your code I got a good match, try it out yourself:

map <- treeMap(tls, map.hough(min_h = 2, max_h = 6, h_step = 2, min_density = 0.01, max_d = 0.8, pixel_size = 0.03))

Given the low point cloud density, especially below canopy, you need to apply more "embracing" parameters. Decreasing the min_density and increasing the pixel_size were good calls. But considering that the algorithm operates in layers, it's likely that narrow height intervals will have too few points below the canopy layer, so increasing the h_step did the trick here.

It was not a bug, so I just added an error message to map.hough warning whenever the algorithm doesn't match any points for the chosen parameters.

Thanks for opening the issue!

mansi-aggarwal-2504 commented 3 years ago

Thank you so much for your help @tiagodc.

aasthaagarwal17 commented 3 years ago

Hi @tiagodc , I have used the same file of @mansi-aggarwal-2504 using TreeLS v1 map.hough(hmin =6 hmax = 9 , hstep = 0.5, min_density = 0.01, max_radius = 0.4, pixel_size = 0.10) at specified hmin and hmax and I was able to detect 1 tree, but it produced an error while running the same code using TreeLS v2 as specified by @mansi-aggarwal-2504 . What might be the reason for same? Thanks.

tiagodc commented 3 years ago

Hi @aasthaagarwal17 There is a new merge parameter in treeMap in this version for applying treeMap.merge internally. It tries to identify and merge different IDs that belong to the same tree. The original error came from passing an empty point cloud to treeMap.merge internally. You can use merge=0 in treeMap to ignore this optimization step, this way the results should be exactly the same as in v1.