Be careful! The write function doesn't create a file, you have to use an existing one. Don't write to a file you don't want to update by mistake.
vapour_write_raster_block(
dsource,
data,
offset,
dimension,
band = 1L,
overwrite = FALSE
)
data source name
data vector, length should match prod(dimension)
or length 1 allowed
offset to start
dimension to write
which band to write to (1-based)
set to FALSE as a safety valve to not overwrite an existing file
a logical value indicating success (or failure) of the write
f <- system.file("extdata", "sst.tif", package = "vapour")
v <- vapour_read_raster_block(f, c(0L, 0L), dimension = c(2L, 3L), band = 1L)
file.copy(f, tf <- tempfile(fileext = ".tif"))
#> [1] TRUE
try(vapour_write_raster_block(tf, data = v[[1]], offset = c(0L, 0L),
dimension = c(2L, 3L), band = 1L))
#> Error in vapour_write_raster_block(tf, data = v[[1]], offset = c(0L, 0L), :
#> set 'overwrite' to TRUE if you really mean to write to file /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmpk7Ckn4/file5e3cfa5a71c.tif
if (file.exists(tf)) file.remove(tf)
#> [1] TRUE