This notebook has been slightly adapted from session3.2-lidR-LAS-class.Rmd
included in the LiDAR course material by CSC. Their material in turn is based on the lidR wiki documentation.
lidr is an R package for Airborne LiDAR Data Manipulation and Visualization for Forestry Applications.
lidR rovides functions to read and write .las
and .laz
files, plot point clouds, compute metrics using an area-based approach, compute digital canopy models, thin lidar data etc.
library("lidR")
## Loading required package: raster
## Loading required package: sp
From the download service by National Land Survey of Finland/Maanmittauslaitos (NLSF/MML) I ordered the grid labelled L4132D2 which is inside the Nuuksio National Park in Espoo.
The zipped file is around 100 MB, and the metadata tells e.g. that the scanning was done on 2.8.2015 from the flight altitude of 2033 m with a Leica ALS 60 scanner.
The lidR package can read zipped LAZ files so I ignored the advice by NLSF to unzip it first with the laszip tool.
LASfile <- "L4132D2.laz"
las <- readLAS(LASfile)
print(las)
## class : LAS (LASF v1.2)
## point format : 1
## memory : 1.6 Gb
## extent :362000, 365000, 6687000, 6690000 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
## area : 9 km²
## points : 21.47 million points
## density : 2.39 points/m²
## names : X Y Z gpstime Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification Synthetic_flag Keypoint_flag Withheld_flag ScanAngleRank UserData PointSourceID
The memory use of this las
object is a whopping 1.6 Gb so as advised I clipped it down to 500 x 500 m. The original covered an area of 9 km2.
las_small <- lasclipRectangle(las, las@bbox[1], las@bbox[2], las@bbox[1] + 500, las@bbox[2] + 500)
print(las_small)
## class : LAS (LASF v1.2)
## point format : 1
## memory : 73.4 Mb
## extent :362000, 362500, 6687000, 6687500 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
## area : 246692.5 m²
## points : 961.6 thoushand points
## density : 3.9 points/m²
## names : X Y Z gpstime Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification Synthetic_flag Keypoint_flag Withheld_flag ScanAngleRank UserData PointSourceID
rm(las)
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 1528732 81.7 2500322 133.6 2500322 133.6
## Vcells 11954366 91.3 277056916 2113.8 346321144 2642.3
The grid_terrain
function creates a DTM by interpolating ground points. Here, we use the tin
algorithm. The result is an R RasterLayer.
dtm <- grid_terrain(las_small, algorithm = tin())
plot(dtm)
The following is adapted from the Segment individual trees and compute metrics example by Jean-Romain.
One of the several algorithm by lasground
to classify ground points is csf
. From the documentation:
Cloth Simulation Filter (CSF) is an airborne LiDAR (Light Detection and Ranging) ground points filtering algorithm which is based on cloth simulation. It tries to simulate the interactions between the cloth nodes and the corresponding LiDAR points, the locations of the cloth nodes can be determined to generate an approximation of the ground surface.
las_small <- lasground(las_small, csf())
## Original dataset already contains 127999 ground points. These points were reclassified as 'unclassified' before performing a new ground classification.
plot(las_small, color = "Classification")
For tree segementation we will use an algorithm that requires a canopy height model, so first we compute a digital surface model using the pit-free
algorithm.
algo = pitfree(thresholds = c(0,10,20,30,40,50), subcircle = 0.2)
chm = grid_canopy(las_small, 0.5, algo)
## Searching in TIN: [===========---------------------------------------] 22% (4 threads)
Searching in TIN: [===========---------------------------------------] 23% (4 threads)
Searching in TIN: [============--------------------------------------] 24% (4 threads)
Searching in TIN: [============--------------------------------------] 25% (4 threads)
Searching in TIN: [=============-------------------------------------] 26% (4 threads)
Searching in TIN: [=============-------------------------------------] 27% (4 threads)
Searching in TIN: [==============------------------------------------] 28% (4 threads)
Searching in TIN: [==============------------------------------------] 29% (4 threads)
Searching in TIN: [===============-----------------------------------] 30% (4 threads)
Searching in TIN: [===============-----------------------------------] 31% (4 threads)
Searching in TIN: [================----------------------------------] 32% (4 threads)
Searching in TIN: [================----------------------------------] 33% (4 threads)
Searching in TIN: [=================---------------------------------] 34% (4 threads)
Searching in TIN: [=================---------------------------------] 35% (4 threads)
Searching in TIN: [==================--------------------------------] 36% (4 threads)
Searching in TIN: [==================--------------------------------] 37% (4 threads)
Searching in TIN: [===================-------------------------------] 38% (4 threads)
Searching in TIN: [===================-------------------------------] 39% (4 threads)
Searching in TIN: [====================------------------------------] 40% (4 threads)
Searching in TIN: [====================------------------------------] 41% (4 threads)
Searching in TIN: [=====================-----------------------------] 42% (4 threads)
Searching in TIN: [=====================-----------------------------] 43% (4 threads)
Searching in TIN: [======================----------------------------] 44% (4 threads)
Searching in TIN: [======================----------------------------] 45% (4 threads)
Searching in TIN: [=======================---------------------------] 46% (4 threads)
Searching in TIN: [=======================---------------------------] 47% (4 threads)
Searching in TIN: [========================--------------------------] 48% (4 threads)
Searching in TIN: [========================--------------------------] 49% (4 threads)
Searching in TIN: [=========================-------------------------] 50% (4 threads)
Searching in TIN: [=========================-------------------------] 51% (4 threads)
Searching in TIN: [==========================------------------------] 52% (4 threads)
Searching in TIN: [==========================------------------------] 53% (4 threads)
Searching in TIN: [===========================-----------------------] 54% (4 threads)
Searching in TIN: [===========================-----------------------] 55% (4 threads)
Searching in TIN: [============================----------------------] 56% (4 threads)
Searching in TIN: [============================----------------------] 57% (4 threads)
Searching in TIN: [=============================---------------------] 58% (4 threads)
Searching in TIN: [=============================---------------------] 59% (4 threads)
Searching in TIN: [==============================--------------------] 60% (4 threads)
Searching in TIN: [==============================--------------------] 61% (4 threads)
Searching in TIN: [===============================-------------------] 62% (4 threads)
Searching in TIN: [===============================-------------------] 63% (4 threads)
Searching in TIN: [================================------------------] 64% (4 threads)
Searching in TIN: [================================------------------] 65% (4 threads)
Searching in TIN: [=================================-----------------] 66% (4 threads)
Searching in TIN: [=================================-----------------] 67% (4 threads)
Searching in TIN: [==================================----------------] 68% (4 threads)
Searching in TIN: [==================================----------------] 69% (4 threads)
Searching in TIN: [===================================---------------] 70% (4 threads)
Searching in TIN: [===================================---------------] 71% (4 threads)
Searching in TIN: [====================================--------------] 72% (4 threads)
Searching in TIN: [====================================--------------] 73% (4 threads)
Searching in TIN: [=====================================-------------] 74% (4 threads)
Searching in TIN: [=====================================-------------] 75% (4 threads)
Searching in TIN: [======================================------------] 76% (4 threads)
Searching in TIN: [======================================------------] 77% (4 threads)
Searching in TIN: [=======================================-----------] 78% (4 threads)
Searching in TIN: [=======================================-----------] 79% (4 threads)
Searching in TIN: [========================================----------] 80% (4 threads)
Searching in TIN: [========================================----------] 81% (4 threads)
Searching in TIN: [=========================================---------] 82% (4 threads)
Searching in TIN: [=========================================---------] 83% (4 threads)
Searching in TIN: [==========================================--------] 84% (4 threads)
Searching in TIN: [==========================================--------] 85% (4 threads)
Searching in TIN: [===========================================-------] 86% (4 threads)
Searching in TIN: [===========================================-------] 87% (4 threads)
Searching in TIN: [============================================------] 88% (4 threads)
Searching in TIN: [============================================------] 89% (4 threads)
Searching in TIN: [=============================================-----] 90% (4 threads)
Searching in TIN: [=============================================-----] 91% (4 threads)
Searching in TIN: [==============================================----] 92% (4 threads)
Searching in TIN: [==============================================----] 93% (4 threads)
Searching in TIN: [===============================================---] 94% (4 threads)
Searching in TIN: [===============================================---] 95% (4 threads)
Searching in TIN: [================================================--] 96% (4 threads)
Searching in TIN: [================================================--] 97% (4 threads)
Searching in TIN: [=================================================-] 98% (4 threads)
Searching in TIN: [=================================================-] 99% (4 threads)
Searching in TIN: [==================================================] 100% (4 threads)
Searching in TIN: [================----------------------------------] 32% (4 threads)
Searching in TIN: [================----------------------------------] 33% (4 threads)
Searching in TIN: [=================---------------------------------] 34% (4 threads)
Searching in TIN: [=================---------------------------------] 35% (4 threads)
Searching in TIN: [==================--------------------------------] 36% (4 threads)
Searching in TIN: [==================--------------------------------] 37% (4 threads)
Searching in TIN: [===================-------------------------------] 38% (4 threads)
Searching in TIN: [===================-------------------------------] 39% (4 threads)
Searching in TIN: [====================------------------------------] 40% (4 threads)
Searching in TIN: [====================------------------------------] 41% (4 threads)
Searching in TIN: [=====================-----------------------------] 42% (4 threads)
Searching in TIN: [=====================-----------------------------] 43% (4 threads)
Searching in TIN: [======================----------------------------] 44% (4 threads)
Searching in TIN: [======================----------------------------] 45% (4 threads)
Searching in TIN: [=======================---------------------------] 46% (4 threads)
Searching in TIN: [=======================---------------------------] 47% (4 threads)
Searching in TIN: [========================--------------------------] 48% (4 threads)
Searching in TIN: [========================--------------------------] 49% (4 threads)
Searching in TIN: [=========================-------------------------] 50% (4 threads)
Searching in TIN: [=========================-------------------------] 51% (4 threads)
Searching in TIN: [==========================------------------------] 52% (4 threads)
Searching in TIN: [==========================------------------------] 53% (4 threads)
Searching in TIN: [===========================-----------------------] 54% (4 threads)
Searching in TIN: [===========================-----------------------] 55% (4 threads)
Searching in TIN: [============================----------------------] 56% (4 threads)
Searching in TIN: [============================----------------------] 57% (4 threads)
Searching in TIN: [=============================---------------------] 58% (4 threads)
Searching in TIN: [=============================---------------------] 59% (4 threads)
Searching in TIN: [==============================--------------------] 60% (4 threads)
Searching in TIN: [==============================--------------------] 61% (4 threads)
Searching in TIN: [===============================-------------------] 62% (4 threads)
Searching in TIN: [===============================-------------------] 63% (4 threads)
Searching in TIN: [================================------------------] 64% (4 threads)
Searching in TIN: [================================------------------] 65% (4 threads)
Searching in TIN: [=================================-----------------] 66% (4 threads)
Searching in TIN: [=================================-----------------] 67% (4 threads)
Searching in TIN: [==================================----------------] 68% (4 threads)
Searching in TIN: [==================================----------------] 69% (4 threads)
Searching in TIN: [===================================---------------] 70% (4 threads)
Searching in TIN: [===================================---------------] 71% (4 threads)
Searching in TIN: [====================================--------------] 72% (4 threads)
Searching in TIN: [====================================--------------] 73% (4 threads)
Searching in TIN: [=====================================-------------] 74% (4 threads)
Searching in TIN: [=====================================-------------] 75% (4 threads)
Searching in TIN: [======================================------------] 76% (4 threads)
Searching in TIN: [======================================------------] 77% (4 threads)
Searching in TIN: [=======================================-----------] 78% (4 threads)
Searching in TIN: [=======================================-----------] 79% (4 threads)
Searching in TIN: [========================================----------] 80% (4 threads)
Searching in TIN: [========================================----------] 81% (4 threads)
Searching in TIN: [=========================================---------] 82% (4 threads)
Searching in TIN: [=========================================---------] 83% (4 threads)
Searching in TIN: [==========================================--------] 84% (4 threads)
Searching in TIN: [==========================================--------] 85% (4 threads)
Searching in TIN: [===========================================-------] 86% (4 threads)
Searching in TIN: [===========================================-------] 87% (4 threads)
Searching in TIN: [============================================------] 88% (4 threads)
Searching in TIN: [============================================------] 89% (4 threads)
Searching in TIN: [=============================================-----] 90% (4 threads)
Searching in TIN: [=============================================-----] 91% (4 threads)
Searching in TIN: [==============================================----] 92% (4 threads)
Searching in TIN: [==============================================----] 93% (4 threads)
Searching in TIN: [===============================================---] 94% (4 threads)
Searching in TIN: [===============================================---] 95% (4 threads)
Searching in TIN: [================================================--] 96% (4 threads)
Searching in TIN: [================================================--] 97% (4 threads)
Searching in TIN: [=================================================-] 98% (4 threads)
Searching in TIN: [=================================================-] 99% (4 threads)
Searching in TIN: [==================================================] 100% (4 threads)
Searching in TIN: [================----------------------------------] 32% (4 threads)
Searching in TIN: [================----------------------------------] 33% (4 threads)
Searching in TIN: [=================---------------------------------] 34% (4 threads)
Searching in TIN: [=================---------------------------------] 35% (4 threads)
Searching in TIN: [==================--------------------------------] 36% (4 threads)
Searching in TIN: [==================--------------------------------] 37% (4 threads)
Searching in TIN: [===================-------------------------------] 38% (4 threads)
Searching in TIN: [===================-------------------------------] 39% (4 threads)
Searching in TIN: [====================------------------------------] 40% (4 threads)
Searching in TIN: [====================------------------------------] 41% (4 threads)
Searching in TIN: [=====================-----------------------------] 42% (4 threads)
Searching in TIN: [=====================-----------------------------] 43% (4 threads)
Searching in TIN: [======================----------------------------] 44% (4 threads)
Searching in TIN: [======================----------------------------] 45% (4 threads)
Searching in TIN: [=======================---------------------------] 46% (4 threads)
Searching in TIN: [=======================---------------------------] 47% (4 threads)
Searching in TIN: [========================--------------------------] 48% (4 threads)
Searching in TIN: [========================--------------------------] 49% (4 threads)
Searching in TIN: [=========================-------------------------] 50% (4 threads)
Searching in TIN: [=========================-------------------------] 51% (4 threads)
Searching in TIN: [==========================------------------------] 52% (4 threads)
Searching in TIN: [==========================------------------------] 53% (4 threads)
Searching in TIN: [===========================-----------------------] 54% (4 threads)
Searching in TIN: [===========================-----------------------] 55% (4 threads)
Searching in TIN: [============================----------------------] 56% (4 threads)
Searching in TIN: [============================----------------------] 57% (4 threads)
Searching in TIN: [=============================---------------------] 58% (4 threads)
Searching in TIN: [=============================---------------------] 59% (4 threads)
Searching in TIN: [==============================--------------------] 60% (4 threads)
Searching in TIN: [==============================--------------------] 61% (4 threads)
Searching in TIN: [===============================-------------------] 62% (4 threads)
Searching in TIN: [===============================-------------------] 63% (4 threads)
Searching in TIN: [================================------------------] 64% (4 threads)
Searching in TIN: [================================------------------] 65% (4 threads)
Searching in TIN: [=================================-----------------] 66% (4 threads)
Searching in TIN: [=================================-----------------] 67% (4 threads)
Searching in TIN: [==================================----------------] 68% (4 threads)
Searching in TIN: [==================================----------------] 69% (4 threads)
Searching in TIN: [===================================---------------] 70% (4 threads)
Searching in TIN: [===================================---------------] 71% (4 threads)
Searching in TIN: [====================================--------------] 72% (4 threads)
Searching in TIN: [====================================--------------] 73% (4 threads)
Searching in TIN: [=====================================-------------] 74% (4 threads)
Searching in TIN: [=====================================-------------] 75% (4 threads)
Searching in TIN: [======================================------------] 76% (4 threads)
Searching in TIN: [======================================------------] 77% (4 threads)
Searching in TIN: [=======================================-----------] 78% (4 threads)
Searching in TIN: [=======================================-----------] 79% (4 threads)
Searching in TIN: [========================================----------] 80% (4 threads)
Searching in TIN: [========================================----------] 81% (4 threads)
Searching in TIN: [=========================================---------] 82% (4 threads)
Searching in TIN: [=========================================---------] 83% (4 threads)
Searching in TIN: [==========================================--------] 84% (4 threads)
Searching in TIN: [==========================================--------] 85% (4 threads)
Searching in TIN: [===========================================-------] 86% (4 threads)
Searching in TIN: [===========================================-------] 87% (4 threads)
Searching in TIN: [============================================------] 88% (4 threads)
Searching in TIN: [============================================------] 89% (4 threads)
Searching in TIN: [=============================================-----] 90% (4 threads)
Searching in TIN: [=============================================-----] 91% (4 threads)
Searching in TIN: [==============================================----] 92% (4 threads)
Searching in TIN: [==============================================----] 93% (4 threads)
Searching in TIN: [===============================================---] 94% (4 threads)
Searching in TIN: [===============================================---] 95% (4 threads)
Searching in TIN: [================================================--] 96% (4 threads)
Searching in TIN: [================================================--] 97% (4 threads)
Searching in TIN: [=================================================-] 98% (4 threads)
Searching in TIN: [=================================================-] 99% (4 threads)
Searching in TIN: [==================================================] 100% (4 threads)
Searching in TIN: [===============-----------------------------------] 31% (4 threads)
Searching in TIN: [================----------------------------------] 32% (4 threads)
Searching in TIN: [================----------------------------------] 33% (4 threads)
Searching in TIN: [=================---------------------------------] 34% (4 threads)
Searching in TIN: [=================---------------------------------] 35% (4 threads)
Searching in TIN: [==================--------------------------------] 36% (4 threads)
Searching in TIN: [==================--------------------------------] 37% (4 threads)
Searching in TIN: [===================-------------------------------] 38% (4 threads)
Searching in TIN: [===================-------------------------------] 39% (4 threads)
Searching in TIN: [====================------------------------------] 40% (4 threads)
Searching in TIN: [====================------------------------------] 41% (4 threads)
Searching in TIN: [=====================-----------------------------] 42% (4 threads)
Searching in TIN: [=====================-----------------------------] 43% (4 threads)
Searching in TIN: [======================----------------------------] 44% (4 threads)
Searching in TIN: [======================----------------------------] 45% (4 threads)
Searching in TIN: [=======================---------------------------] 46% (4 threads)
Searching in TIN: [=======================---------------------------] 47% (4 threads)
Searching in TIN: [========================--------------------------] 48% (4 threads)
Searching in TIN: [========================--------------------------] 49% (4 threads)
Searching in TIN: [=========================-------------------------] 50% (4 threads)
Searching in TIN: [=========================-------------------------] 51% (4 threads)
Searching in TIN: [==========================------------------------] 52% (4 threads)
Searching in TIN: [==========================------------------------] 53% (4 threads)
Searching in TIN: [===========================-----------------------] 54% (4 threads)
Searching in TIN: [===========================-----------------------] 55% (4 threads)
Searching in TIN: [============================----------------------] 56% (4 threads)
Searching in TIN: [============================----------------------] 57% (4 threads)
Searching in TIN: [=============================---------------------] 58% (4 threads)
Searching in TIN: [=============================---------------------] 59% (4 threads)
Searching in TIN: [==============================--------------------] 60% (4 threads)
Searching in TIN: [==============================--------------------] 61% (4 threads)
Searching in TIN: [===============================-------------------] 62% (4 threads)
Searching in TIN: [===============================-------------------] 63% (4 threads)
Searching in TIN: [================================------------------] 64% (4 threads)
Searching in TIN: [================================------------------] 65% (4 threads)
Searching in TIN: [=================================-----------------] 66% (4 threads)
Searching in TIN: [=================================-----------------] 67% (4 threads)
Searching in TIN: [==================================----------------] 68% (4 threads)
Searching in TIN: [==================================----------------] 69% (4 threads)
Searching in TIN: [===================================---------------] 70% (4 threads)
Searching in TIN: [===================================---------------] 71% (4 threads)
Searching in TIN: [====================================--------------] 72% (4 threads)
Searching in TIN: [====================================--------------] 73% (4 threads)
Searching in TIN: [=====================================-------------] 74% (4 threads)
Searching in TIN: [=====================================-------------] 75% (4 threads)
Searching in TIN: [======================================------------] 76% (4 threads)
Searching in TIN: [======================================------------] 77% (4 threads)
Searching in TIN: [=======================================-----------] 78% (4 threads)
Searching in TIN: [=======================================-----------] 79% (4 threads)
Searching in TIN: [========================================----------] 80% (4 threads)
Searching in TIN: [========================================----------] 81% (4 threads)
Searching in TIN: [=========================================---------] 82% (4 threads)
Searching in TIN: [=========================================---------] 83% (4 threads)
Searching in TIN: [==========================================--------] 84% (4 threads)
Searching in TIN: [==========================================--------] 85% (4 threads)
Searching in TIN: [===========================================-------] 86% (4 threads)
Searching in TIN: [===========================================-------] 87% (4 threads)
Searching in TIN: [============================================------] 88% (4 threads)
Searching in TIN: [============================================------] 89% (4 threads)
Searching in TIN: [=============================================-----] 90% (4 threads)
Searching in TIN: [=============================================-----] 91% (4 threads)
Searching in TIN: [==============================================----] 92% (4 threads)
Searching in TIN: [==============================================----] 93% (4 threads)
Searching in TIN: [===============================================---] 94% (4 threads)
Searching in TIN: [===============================================---] 95% (4 threads)
Searching in TIN: [================================================--] 96% (4 threads)
Searching in TIN: [================================================--] 97% (4 threads)
Searching in TIN: [=================================================-] 98% (4 threads)
Searching in TIN: [=================================================-] 99% (4 threads)
Searching in TIN: [==================================================] 100% (4 threads)
Searching in TIN: [================----------------------------------] 32% (4 threads)
Searching in TIN: [================----------------------------------] 33% (4 threads)
Searching in TIN: [=================---------------------------------] 34% (4 threads)
Searching in TIN: [=================---------------------------------] 35% (4 threads)
Searching in TIN: [==================--------------------------------] 36% (4 threads)
Searching in TIN: [==================--------------------------------] 37% (4 threads)
Searching in TIN: [===================-------------------------------] 38% (4 threads)
Searching in TIN: [===================-------------------------------] 39% (4 threads)
Searching in TIN: [====================------------------------------] 40% (4 threads)
Searching in TIN: [====================------------------------------] 41% (4 threads)
Searching in TIN: [=====================-----------------------------] 42% (4 threads)
Searching in TIN: [=====================-----------------------------] 43% (4 threads)
Searching in TIN: [======================----------------------------] 44% (4 threads)
Searching in TIN: [======================----------------------------] 45% (4 threads)
Searching in TIN: [=======================---------------------------] 46% (4 threads)
Searching in TIN: [=======================---------------------------] 47% (4 threads)
Searching in TIN: [========================--------------------------] 48% (4 threads)
Searching in TIN: [========================--------------------------] 49% (4 threads)
Searching in TIN: [=========================-------------------------] 50% (4 threads)
Searching in TIN: [=========================-------------------------] 51% (4 threads)
Searching in TIN: [==========================------------------------] 52% (4 threads)
Searching in TIN: [==========================------------------------] 53% (4 threads)
Searching in TIN: [===========================-----------------------] 54% (4 threads)
Searching in TIN: [===========================-----------------------] 55% (4 threads)
Searching in TIN: [============================----------------------] 56% (4 threads)
Searching in TIN: [============================----------------------] 57% (4 threads)
Searching in TIN: [=============================---------------------] 58% (4 threads)
Searching in TIN: [=============================---------------------] 59% (4 threads)
Searching in TIN: [==============================--------------------] 60% (4 threads)
Searching in TIN: [==============================--------------------] 61% (4 threads)
Searching in TIN: [===============================-------------------] 62% (4 threads)
Searching in TIN: [===============================-------------------] 63% (4 threads)
Searching in TIN: [================================------------------] 64% (4 threads)
Searching in TIN: [================================------------------] 65% (4 threads)
Searching in TIN: [=================================-----------------] 66% (4 threads)
Searching in TIN: [=================================-----------------] 67% (4 threads)
Searching in TIN: [==================================----------------] 68% (4 threads)
Searching in TIN: [==================================----------------] 69% (4 threads)
Searching in TIN: [===================================---------------] 70% (4 threads)
Searching in TIN: [===================================---------------] 71% (4 threads)
Searching in TIN: [====================================--------------] 72% (4 threads)
Searching in TIN: [====================================--------------] 73% (4 threads)
Searching in TIN: [=====================================-------------] 74% (4 threads)
Searching in TIN: [=====================================-------------] 75% (4 threads)
Searching in TIN: [======================================------------] 76% (4 threads)
Searching in TIN: [======================================------------] 77% (4 threads)
Searching in TIN: [=======================================-----------] 78% (4 threads)
Searching in TIN: [=======================================-----------] 79% (4 threads)
Searching in TIN: [========================================----------] 80% (4 threads)
Searching in TIN: [========================================----------] 81% (4 threads)
Searching in TIN: [=========================================---------] 82% (4 threads)
Searching in TIN: [=========================================---------] 83% (4 threads)
Searching in TIN: [==========================================--------] 84% (4 threads)
Searching in TIN: [==========================================--------] 85% (4 threads)
Searching in TIN: [===========================================-------] 86% (4 threads)
Searching in TIN: [===========================================-------] 87% (4 threads)
Searching in TIN: [============================================------] 88% (4 threads)
Searching in TIN: [============================================------] 89% (4 threads)
Searching in TIN: [=============================================-----] 90% (4 threads)
Searching in TIN: [=============================================-----] 91% (4 threads)
Searching in TIN: [==============================================----] 92% (4 threads)
Searching in TIN: [==============================================----] 93% (4 threads)
Searching in TIN: [===============================================---] 94% (4 threads)
Searching in TIN: [===============================================---] 95% (4 threads)
Searching in TIN: [================================================--] 96% (4 threads)
Searching in TIN: [================================================--] 97% (4 threads)
Searching in TIN: [=================================================-] 98% (4 threads)
Searching in TIN: [=================================================-] 99% (4 threads)
Searching in TIN: [==================================================] 100% (4 threads)
Searching in TIN: [===================-------------------------------] 39% (4 threads)
Searching in TIN: [====================------------------------------] 40% (4 threads)
Searching in TIN: [====================------------------------------] 41% (4 threads)
Searching in TIN: [=====================-----------------------------] 42% (4 threads)
Searching in TIN: [=====================-----------------------------] 43% (4 threads)
Searching in TIN: [======================----------------------------] 44% (4 threads)
Searching in TIN: [======================----------------------------] 45% (4 threads)
Searching in TIN: [=======================---------------------------] 46% (4 threads)
Searching in TIN: [=======================---------------------------] 47% (4 threads)
Searching in TIN: [========================--------------------------] 48% (4 threads)
Searching in TIN: [========================--------------------------] 49% (4 threads)
Searching in TIN: [=========================-------------------------] 50% (4 threads)
Searching in TIN: [=========================-------------------------] 51% (4 threads)
Searching in TIN: [==========================------------------------] 52% (4 threads)
Searching in TIN: [==========================------------------------] 53% (4 threads)
Searching in TIN: [===========================-----------------------] 54% (4 threads)
Searching in TIN: [===========================-----------------------] 55% (4 threads)
Searching in TIN: [============================----------------------] 56% (4 threads)
Searching in TIN: [============================----------------------] 57% (4 threads)
Searching in TIN: [=============================---------------------] 58% (4 threads)
Searching in TIN: [=============================---------------------] 59% (4 threads)
Searching in TIN: [==============================--------------------] 60% (4 threads)
Searching in TIN: [==============================--------------------] 61% (4 threads)
Searching in TIN: [===============================-------------------] 62% (4 threads)
Searching in TIN: [===============================-------------------] 63% (4 threads)
Searching in TIN: [================================------------------] 64% (4 threads)
Searching in TIN: [================================------------------] 65% (4 threads)
Searching in TIN: [=================================-----------------] 66% (4 threads)
Searching in TIN: [=================================-----------------] 67% (4 threads)
Searching in TIN: [==================================----------------] 68% (4 threads)
Searching in TIN: [==================================----------------] 69% (4 threads)
Searching in TIN: [===================================---------------] 70% (4 threads)
Searching in TIN: [===================================---------------] 71% (4 threads)
Searching in TIN: [====================================--------------] 72% (4 threads)
Searching in TIN: [====================================--------------] 73% (4 threads)
Searching in TIN: [=====================================-------------] 74% (4 threads)
Searching in TIN: [=====================================-------------] 75% (4 threads)
Searching in TIN: [======================================------------] 76% (4 threads)
Searching in TIN: [======================================------------] 77% (4 threads)
Searching in TIN: [=======================================-----------] 78% (4 threads)
Searching in TIN: [=======================================-----------] 79% (4 threads)
Searching in TIN: [========================================----------] 80% (4 threads)
Searching in TIN: [========================================----------] 81% (4 threads)
Searching in TIN: [=========================================---------] 82% (4 threads)
Searching in TIN: [=========================================---------] 83% (4 threads)
Searching in TIN: [==========================================--------] 84% (4 threads)
Searching in TIN: [==========================================--------] 85% (4 threads)
Searching in TIN: [===========================================-------] 86% (4 threads)
Searching in TIN: [===========================================-------] 87% (4 threads)
Searching in TIN: [============================================------] 88% (4 threads)
Searching in TIN: [============================================------] 89% (4 threads)
Searching in TIN: [=============================================-----] 90% (4 threads)
Searching in TIN: [=============================================-----] 91% (4 threads)
Searching in TIN: [==============================================----] 92% (4 threads)
Searching in TIN: [==============================================----] 93% (4 threads)
Searching in TIN: [===============================================---] 94% (4 threads)
Searching in TIN: [===============================================---] 95% (4 threads)
Searching in TIN: [================================================--] 96% (4 threads)
Searching in TIN: [================================================--] 97% (4 threads)
Searching in TIN: [=================================================-] 98% (4 threads)
Searching in TIN: [=================================================-] 99% (4 threads)
Searching in TIN: [==================================================] 100% (4 threads)
plot(chm, col = height.colors(50))
The segmentation can be done with lastrees
. Let’s use the watershed
algorithm with a threshold of 4 meters.
algo <- watershed(chm, th = 4)
las_small <- lastrees(las_small, algo)
trees <- lasfilter(las_small, !is.na(treeID))
plot(trees, color = "treeID", colorPalette = pastel.colors(100))
The point cloud has now been updated and each point has a number that refers to an individual tree (treeID). Points that are not trees are assigned the id value NA.