title: Importing, processing, edit and export .tif files in R
body: <p>I'm working with a .tif image captured from a Sequoia Parrot sensor. I want to do radiometric calibration and export the resulting image in the same format (.tif).</p>
  
  <p>I import the image as a raster, then process with some algorithms and finally try to export as a .tif file but it is impossible to open. The resulting file is 7 MB but the image cannot be viewed.</p>
  
  <p>Here is my script:</p>
  
  <pre><code>setwd("/where the images are/")
  rlist=list.files(getwd(), pattern="TIF$", full.names=F)
  options(digits=20)
  
  for(i in rlist){ 
    data &lt;- raster(i)
  
  meta &lt;- exifr(i, recursive = FALSE, quiet = TRUE, exiftoolargs = NULL)
  SM &lt;- meta$SensorModel
  SM &lt;- strsplit(SM, ",")[[1]]
  A &lt;- as.numeric(SM[1])
  B &lt;- as.numeric(SM[2]) 
  C &lt;- as.numeric(gsub("[^0-9\\.]", "", SM[3]) )
  
  Ep &lt;- meta$ExposureTime   ## Epsilon 
  f &lt;- meta$FNumber   ## Focus Number
  ys &lt;- meta$ISO  ##ISO
  
  I &lt;- f^2*(data-B)/(A*Ep*ys+C)
  I &lt;- flip(I,"x")
  I &lt;- flip(I,"y")
  </code></pre>