vapour_write_raster_block: Write data to a block _in an existing file_.

View source: R/00_read_block.R

vapour_write_raster_blockR Documentation

Write data to a block in an existing file.

Description

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.

Usage

vapour_write_raster_block(
  dsource,
  data,
  offset,
  dimension,
  band = 1L,
  overwrite = FALSE
)

Arguments

dsource

data source name

data

data vector, length should match prod(dimension) or length 1 allowed

offset

offset to start

dimension

dimension to write

band

which band to write to (1-based)

overwrite

set to FALSE as a safety valve to not overwrite an existing file

Value

a logical value indicating success (or failure) of the write

Examples

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"))
try(vapour_write_raster_block(tf, data = v[[1]], offset = c(0L, 0L), 
               dimension = c(2L, 3L), band = 1L))
if (file.exists(tf)) file.remove(tf)

vapour documentation built on April 11, 2023, 5:59 p.m.