0

I am currently using the LidR package to rasterize a canopy height model from a LAScatalog object:

opt_output_files(ctg_norm) <-  paste0("C:/Programming/C_Forstenried/las_outputs/temp/{*}chm")
chm1 <- rasterize_canopy(ctg_norm, res = 0.5, algorithm = p2r(), overwrite =TRUE)
chm2 <- rasterize_canopy(ctg_norm, res = 0.25, algorithm = p2r(subcircle = 0.15), overwrite = TRUE)

However, on the second run, I am stopped by the following error:

Error: [writeRaster] file exists. You can use 'overwrite=TRUE' to overwrite it

Has anyone else encountered this problem? I found this (fairly old) forum post: Configuring lidR catalog to overwrite raster output (with different extension)?, but it did not help. I tried adding overwrites to the terra and raster packages:

library(terra)
options(overwrite = TRUE)
library(raster)
rasterOptions(overwrite = TRUE)

and added the overwrite = TRUE parameter to the rasterize_canopy function. I also tried adding this line from the aforementioned forum post:

ctg_norm@output_options$drivers$Raster$param$overwrite <- TRUE

but to no avail. When I manually change the output file path, it works again, but overwriting would be much more convenient.

Any ideas? I am fairly new to coding...

0

0

Browse other questions tagged or ask your own question.