Learn R Programming

detrendr (version 0.1.0)

write_tif: Write an integer array to disk as a tiff image.

Description

This function allows you to write integer-valued arrays to disk as tiff files as you would want, which is cumbersome with tiff::writeTIFF().

Usage

write_tif(img, file_name, na = "error", rds = TRUE)

Arguments

img

An integer array.

file_name

The name of the tif file (with or without the .tif) that you wish to write.

na

How do you want to treat NA values? R can only write integer values (and hence not NAs) to tiff pixels. na = 'saturate' sets them to saturated value. na = 'zero' sets them to zero, while na = 'error' will give an error if the image contains NAs. You can also specify directly here a natural number (must be between 0 and 2 ^ 32 - 1) to use in place of NAs.

rds

In addition to writing a TIFF file, do you want to save an RDS (a single R object) file?

Examples

Run this code
# NOT RUN {
img <- read_tif(system.file('extdata', 'bleached.tif', package = 'detrendr'),
                 n_ch = 1)
setwd(tempdir())
write_tif(img, 'bleached.tif')
suppressWarnings(file.remove(list.files()))  # cleanup

# }

Run the code above in your browser using DataLab