avli avli - 4 months ago 19
R Question

What is the simplest way to display raster image in R?

I'm working with TIFF images in R. I load images as

library(tiff)
img <- readTIFF("someimage.tiff")


I'm manipulating with
img
array then and want to see the results. One of the options is use
writeTIFF
function to store the image on disk and open it with image viewer. However I wish to have some simple way to display images inside R. What would you recommend?

Answer

here's one option:

img <- readTIFF(system.file("img", "Rlogo.tiff", package="tiff"))
grid::grid.raster(img)