I'm trying to test my pixel_metrics() custom function, and I'm not sure how to overwrite the old file, like the error message suggests in the screenshot. I have added overwrite=TRUE
to my function call, but it doesn't seem to be working.
It seems like internally pixel_metrics() is calling writeRaster() -- maybe there is a way to propagate overwrite=TRUE
to writeRaster() ?
Function call:
canopy_metrics = pixel_metrics(norm, ~lcp_pixel_metrics(Z, ReturnNumber), 16.4042, overwrite=TRUE)
Error message:
r: [writeRaster] file exists. You can use 'overwrite=TRUE' to overwrite it
In addition, I've tried running the following line of code, inspired by this post.
canopy_metrics@output_options$drivers$Raster$param$overwrite <- TRUE
But R says that "output_options" does not exist for class "SpatRaster."
debug(writeRaster)
and then see how its being called...