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

4.0 Find_trees output sp object not sf #503

Closed liamirwin closed 2 years ago

liamirwin commented 2 years ago

Hi JR,

Wanted to alert you to the fact that find_trees is still outputting sp objects,

Will be in touch with 4.0 issues as I come across them.

Reprex attached,

Thanks

Liam

# Issue: Output of find_trees function is SpatialPointsDataframe not sf object

library(lidR)

packageVersion('lidR')
#> [1] '4.0.0'

las <- readLAS(system.file("extdata", "MixedConifer.laz", package="lidR"))

ttops <- find_trees(las, lmf(ws = 2))

class(ttops)
#> [1] "SpatialPointsDataFrame"
#> attr(,"package")
#> [1] "sp"

Created on 2021-11-24 by the reprex package (v2.0.1)

Jean-Romain commented 2 years ago

Yes it does. It is for backward compatibility. I created new functions that return sf objects but old functions are planned to be backward compatible to do not break user's codes. Please read the changelog for more details.

If you have some code that uses find_trees or other old geospatial stuff please keep going with these old functions. When I asked for beta testers my goal was also to ensure that old codes are not broken. When lidR v4.0.0 will be released however I suggest you to give up with sp and fully use sf and thus the new functions I created (locate_tree in this case)