# Load packages
library(sf)
library(terra)
library(lidR)
library(lidRmetrics)
Excercise Solutions
Resources
1-LAS
E1.
Using the plot()
function plot the point cloud with a different attribute that has not been done yet
Try adding axis = TRUE, legend = TRUE to your plot argument plot(las, axis = TRUE, legend = TRUE)
Code
<- readLAS(files = "data/zrh_norm.laz") las
Code
plot(las, color = "ReturnNumber", axis = TRUE, legend = TRUE)
E2.
Create a filtered las object of returns that have an Intensity greater that 50, and plot it.
Code
<- readLAS(files = "data/zrh_norm.laz") las
Code
<- filter_poi(las = las, Intensity > 50)
i_50 plot(i_50)
E3.
Read in the las file with only xyz and intensity only. Hint go to the lidRbook section to find out how to do this.
Code
<- readLAS(files = "data/zrh_norm.laz", select = "xyzi") las
2-DTM
E1.
Compute two DTMs for this point cloud with differing spatial resolutions, plot both e.g. `plot(dtm1)
E2.
Now use the plot_dtm3d()
function to visualize and move around your newly created DTMs
Code
plot_dtm3d(dtm_5)
3-CHM
E1.
Using the p2r()
and pitfree()
(defining your own arguments) create two CHMs with the same resolution and plot them. What differences do you notice?
Code
<- readLAS(files = "data/zrh_norm.laz") las
Code
<- rasterize_canopy(las=las, res=2, algorithm=p2r())
chm_p2r
<- c(0, 5, 10, 20, 25, 30)
thresholds <- c(0, 1.35)
max_edge <- rasterize_canopy(las = las, res = 2, algorithm = pitfree(thresholds, max_edge))
chm_pitfree
plot(chm_p2r)
Code
plot(chm_pitfree)
E2.
Using terra::focal()
with the w = matrix(1, 5, 5)
and fun = max
, plot a manipulated CHM using one of the CHMs you previously generated.
E3.
Create a 10 m CHM using a algorithm of your choice. Would this information still be useful at this scale?
4-METRICS
E1.
Generate another metric set provided by the lidRmetrics
package (voxel metrics will take too long)
Code
<- readLAS(files = "data/zrh_norm.laz") las
Code
<- pixel_metrics(las, ~metrics_percentiles(z = Z), res = 20) dispersion
E2.
Map the density of ground returns at a 5 m resolution. Hint filter = -keep_class 2
E3.
ssuming that biomass is estimated using the equation B = 0.5 * mean Z + 0.9 * 90th percentile of Z
applied on first returns only, map the biomass.
6-LASCATALOG
E1.
Calculate a set of metrics from the lidRmetrics
package on the catalogue (voxel metrics will take too long)
Code
<- readLAScatalog(folder = "data/ctg_norm")
ctg <- pixel_metrics(ctg, ~metrics_dispersion(z = Z, dz = 2, zmax = 30), res = 20) dispersion
#> Chunk 1 of 9 (11.1%): state ✓
#>
Chunk 2 of 9 (22.2%): state ✓
#>
Chunk 3 of 9 (33.3%): state ✓
#>
Chunk 4 of 9 (44.4%): state ✓
#>
Chunk 5 of 9 (55.6%): state ✓
#>
Chunk 6 of 9 (66.7%): state ✓
#>
Chunk 7 of 9 (77.8%): state ✓
#>
Chunk 8 of 9 (88.9%): state ✓
#>
Chunk 9 of 9 (100%): state ✓
#>
plot(dispersion)
E2.
Read in the non-normalized las catalog filtering the point cloud to only include first returns.
Code
<- readLAScatalog(folder = "data/ctg_class")
ctg opt_filter(ctg) <- "-keep_first -keep_class 2"
E3.
Generate a DTM at 1m spatial resolution for the provided catalog with only first returns.
Code
<- rasterize_terrain(ctg, res = 1, algorithm = tin()) dtm_first
#> Chunk 1 of 9 (11.1%): state ✓
#>
Chunk 2 of 9 (22.2%): state ✓
#>
Chunk 3 of 9 (33.3%): state ✓
#>
Chunk 4 of 9 (44.4%): state ✓
#>
Chunk 5 of 9 (55.6%): state ✓
#>
Chunk 6 of 9 (66.7%): state ✓
#>
Chunk 7 of 9 (77.8%): state ✓
#>
Chunk 8 of 9 (88.9%): state ✓
#>
Chunk 9 of 9 (100%): state ✓
#>
plot(dtm_first)
The Multiple Returns and Canopy Penetration This exercise highlights a critical and unique capability of Airborne Laser Scanning (ALS).
Unlike methods based on imagery like Digital Aerial Photogrammetry (DAP), map the visible surface, LiDAR pulses can penetrate through gaps in the vegetation generating multiple returns each. This allows us to map the ground surface even under dense forest cover, which is essential for creating accurate Digital Terrain Models (DTMs).