# \donttest{
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
ctg = readLAScatalog(LASfile)
plot(ctg)
# Create a new set of 200 x 200 m.las files with first returns only
opt_chunk_buffer(ctg) <- 0
opt_chunk_size(ctg) <- 200
opt_filter(ctg) <- "-keep_first"
opt_chunk_alignment(ctg) <- c(275, 90)
opt_output_files(ctg) <- paste0(tempdir(), "/retile_{XLEFT}_{YBOTTOM}")
# preview the chunk pattern
plot(ctg, chunk = TRUE)
newctg = catalog_retile(ctg)
plot(newctg)
# Create a new set of 200 x 200 m.las files
# but extended with a 50 m buffer in the folder
opt_chunk_buffer(ctg) <- 25
opt_chunk_size(ctg) <- 200
opt_filter(ctg) <- ""
opt_chunk_alignment(ctg) <- c(275, 90)
opt_output_files(ctg) <- paste0(tempdir(), "/{XLEFT}_{YBOTTOM}_buffered")
newctg = catalog_retile(ctg)
plot(newctg)
# }
if (FALSE) {
# Create a new set of compressed .laz file equivalent to the original, keeping only
# first returns above 2 m
opt_chunk_buffer(ctg) <- 0
opt_chunk_size(ctg) <- 0
opt_laz_compression(ctg) <- TRUE
opt_filter(ctg) <- "-keep_first -drop_z_below 2"
opt_output_files(ctg) <- paste0(tempdir(), "/{ORIGINALFILENAME}_first_2m")
newctg = catalog_retile(ctg)
}
Run the code above in your browser using DataLab