tiagodc / TreeLS

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

TreeID from treeMap.positions and stemPoints are not matching #27

Closed aasthaagarwal17 closed 3 years ago

aasthaagarwal17 commented 3 years ago

Hi, here's my code for reference:

map = treeMap(tls, map.hough(min_h = 5, max_h = 8, h_step = 2,
                                   min_density = 0.01, max_d = 0.8, pixel_size = 0.10))

tls_regions = treePoints(tls, map, trp.crop()) 
xymap = treeMap.positions(map, plot = FALSE)

 stem_points = stemPoints(tls_regions, 
                               method = stm.hough(h_step = 0.5,
                                                    max_d = 0.8,
                                                    h_base = c(5,8),
                                                    min_density = 0.01,
                                                    pixel_size = 0.10) ) 

treeId_xymap  <- sort(unique(xymap$TreeID))
treeId_filteredTrees <- sort(unique(stem_points@data$TreeID))

Turns out, treeId_filteredTrees doesn't have all TreeIDs in treeId_xymap

This is something I have noticed in this version of the package only and was not an issue with v1. Can someone explain the reason for this?

tiagodc commented 3 years ago

Hi

I just rerun your code on the data sample from #26 and the IDs are all there:

> treeId_xymap
 [1]  1  2  4  5  6  7  9 10 11 12 14 15
> treeId_filteredTrees
 [1]  0  1  2  4  5  6  7  9 10 11 12 14 15

TreeID on the point cloud is zero for all points not belonging to any tree, so it shouldn't be in the treeMap output anyway, but all other ids match. If you used another dataset and got different results then I would need to see it.

Beware that the algorithms from TreeLS are tuned to find stem features most of the time (even when mapping trees), and they "expect" high point density on the trunks to search for circle/cylinder patterns. If you are using it on ALS data it will probably work also, but the behavior of the algorithms can be unpredictable and yield unreliable results, especially for low density regions with few points on the tree trunks. For instance, on the point cloud from #26 we can see few sparse points on the stems, as well as some large gaps with no data, i.e. empty height intervals below canopy:

x = plot(stem_points, color='Stem', size=3)
add_treeMap(x, xymap, color='yellow')
add_treeIDs(x, xymap, color='yellow')

image