readChar in R is unable to read the tiff tag -
i trying read a tiff file in little endian format. in image file directory first tag value 0100(in hex). when trying read these 2 bytes gives following result.
>readchar(fptr,nchars=2,true) [1] "" when read single bytes correctly gives >readchar(fptr,nchars=1,true) [1] "" >readchar(fptr,nchars=1,true) [1] "\001" >
here's tiff file:
filename <- "test.tiff" tiff(filename) plot(1) dev.off()
you can read in raw bytes using readbin
.
n <- file.info(filename)$size bytes <- readbin(filename, raw(), n = n)
you may prefer read in using tiff::readtiff
.
library(tiff) the_plot <- readtiff(filename)
then can include inside other plots using rasterimage
.
plot(1, 1, 'n') rasterimage(the_plot, 0.8, 0.8, 1.2, 1.2)
Comments
Post a Comment