function to attach polygon attribute to point cloud
Source:R/polygon_attribute_to_las.R
polygon_attribute_to_las.Rdpolygon_attribute_to_las() function to attach polygon attribute to point cloud
Arguments
- las
an object of class LAS
- poly_df
an object of class sf with only POLYGON geometry (use cloud2trees::simplify_multipolygon_crowns() first)
- attribute
character. a data attribute in the
poly_dfthat you want to spatially attach to thelas(e.g. treeID)- force_crs
logical. turn on the force same crs parameter if confident that data are in same projection.
Examples
if (FALSE) { # \dontrun{
# polygon data
f <- system.file(package = "cloud2trees","extdata","crowns_poly.gpkg")
trees_poly <- sf::st_read(f)
# simplify polygons
trees_poly <- simplify_multipolygon_crowns(trees_poly)
# point cloud data
lf <- system.file(package = "cloud2trees","extdata","norm_las","RMNP_017_2018_normalize.las")
las <- lidR::readLAS(lf)
las@data %>% dplyr::glimpse()
# polygon_attribute_to_las to attach treeID to las
las <- polygon_attribute_to_las(las, trees_poly, force_crs = T, attribute = "treeID")
las@data %>% dplyr::glimpse()
} # }