data(chm_chablais3)
chm_chablais3 <- terra::rast(chm_chablais3)
# tree segmentation
segments <- tree_segmentation(chm_chablais3)
# tree extraction
trees <- tree_extraction(segments, crown = TRUE)
# create crown polygons from WKT field
trees_crowns <- sf::st_as_sf(sf::st_drop_geometry(trees), wkt = "crown")
# summary of trees without wkt field
summary(trees[, -which(names(trees) == "crown")])
# plot initial image
terra::plot(chm_chablais3, main = "CHM and extracted trees")
# add treetop positions
plot(trees["h"], add = TRUE, cex = trees$h/20, col = "black")
# add crowns
plot(sf::st_geometry(trees_crowns), add = TRUE, border = "black", col = NA)
# plot segments
terra::plot(segments$segments_id, main = "Segments")
# add crowns
plot(sf::st_geometry(trees_crowns), add = TRUE, border = "black", col = NA)
Run the code above in your browser using DataLab