writeRaster for LAScatalog #654
-
I got an error message “Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘writeRaster’ for signature ‘"LAScatalog", "character" “.. It seems like I cannot use writeRaster for LAScatalog. but this error makes me confused. Here is my code. setwd("E:/Lidar_2022/R/Data_R")
las_cat<-readLAScatalog("E:/Forest_LiDAR/226776/tiles")
opt_output_files(las_cat) <- "E:/Lidar_2022/R/Data_R2/dtm_{XLEFT}_{YBOTTOM}"
dtm <- grid_terrain(las_cat, res = 2, algorithm = knnidw(k=10, p=2, rmax=50), keep_lowest = FALSE)
writeRaster(dtm, "E:/Lidar_2022/R/Data_R/dtm.tif", overwrite=TRUE) **<- no problem in here**
opt_output_files(las_cat) <-"E:/Lidar_2022/R/Data_R2/norm_{XLEFT}_{YBOTTOM}"
MyNorm <- normalize_height(las_cat, dtm)
writeRaster(MyNorm, "E:/Lidar_2022/R/Data_R/chm.tif", overwrite=TRUE) **<- error**
#> Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘writeRaster’ for signature ‘"LAScatalog", "character" The outcome from what is the difference between the two outcomes? I believe both are LAScatalog. And how can I bring back the "dtm" (LAS catalog) from raster (dtm.tif) without re-running When I used a function of Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Beta Was this translation helpful? Give feedback.
grid_terrain
(deprecated, userasterize_terrain
) produces a DTM i.e. a raster. A raster can indeed be written in a raster formatnormalize_height
produces a point cloud. A point cloud is not a raster and cannot be written in a raster formatopt_output_file
to produced the DTM you do not need to usewriteRaster
. The raster is already saved on disk.LAScatalog
is an object handling a collection of las file on disk.rasterize_canopy
produces a CHM.