2

I am studying the foliage density of forest plots below 2 metres in height using mobile terrestrial laser scanning. I want to filter out the tree stems from the point clouds so that the point density estimates do not include them. I have been using the lidR and TreeLS packages to process my point clouds. So far I have normalized the clouds and classified the tree stems using example code given in the TreeLS package documentation:

tls1 = readTLS("tls1.las") %>%
tlsNormalize %>%
tlsSample
map = treeMap(tls1, map.hough())
tls2 = treePoints(tls1, map, trp.crop(circle=FALSE))
tls3 = stemPoints(tls2, stm.hough(pixel_size = 0.03))

This successfully identifies the tree stems.

To filter the stems out, I have tried using the filter_poi() function:

tls4 <- filter_poi(tls3, Stem = "FALSE")

There is a column in the point cloud dataset entitled "Stem" with TRUE/FALSE values so I thought this would work, but I get this error:

Error in lasfilter_(las, lazyeval::dots_capture(...)) : 
  `conditions` must be logical.
3
  • 3
    It is just incorrect R syntax. Use filter_poi(tls3, Stem == FALSE)
    – JRR
    Oct 16, 2020 at 16:41
  • Thanks JRR that works without an error. However, when I then plot the scan before and after filtering the stem points, there is no change in the image. When I look for unique values in the Stem column "TRUE" has been removed, so the filtering has worked. There must be a problem with the stem classification?
    – Amy
    Oct 20, 2020 at 11:08
  • Are you sure the stems were properly segmented initially in tls3? If not it is no longer a lidR question. Can't help.
    – JRR
    Oct 20, 2020 at 11:45

1 Answer 1

1

Try classifying the stems in the 'Classification' column after calling stemPoints.

I've used the following code to classify and then filter stems:

Classify

tls@data[Stem == T, Classification := 20] 

then filter

stems  = filter_poi(tls, Classification == 20L)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.