# NOT RUN {
LASfile <- system.file("extdata", "Topography.laz", package="lidR")
las <- readLAS(LASfile, filter = "-inside 273450 5274350 273550 5274450")
#plot(las)
# First option: use a RasterLayer as DTM
# =======================================================
dtm <- grid_terrain(las, 1, knnidw(k = 6L, p = 2))
las <- normalize_height(las, dtm)
plot(dtm)
#plot(las)
# restore original elevations
las <- unnormalize_height(las)
#plot(las)
# operator - can be used. This is equivalent to the previous
las <- las - dtm
#plot(las)
# restore original elevations
las <- unnormalize_height(las)
# Second option: interpolate each point (no discretization)
# =========================================================
las <- normalize_height(las, tin())
#plot(las)
# operator - can be used. This is equivalent to the previous
las <- unnormalize_height(las)
las <- las - tin()
# }
# NOT RUN {
# All the following syntaxes are correct
las <- normalize_height(las, knnidw())
las <- normalize_height(las, knnidw(k = 8, p = 2))
las <- las - knnidw()
las <- las - knnidw(k = 8)
las <- normalize_height(las, kriging())
las <- las - kriging(k = 8)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab