3

I have a .tif file (about 380 mb) that I am trying to load in R and plot.

file<-raster('tiffname.tif')

It is a formal class Raster Layer with the following information

class       : RasterLayer 
dimensions  : 40000, 40000, 1.6e+09  (nrow, ncol, ncell)
resolution  : 0.00025, 0.00025  (x, y)
extent      : 80, 90, 30, 40  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84+towgs84=0,0,0 
data source : \Data\trial\tiffname.tif 
names       : X40N_080E_mtc02 

Why are there no values for this tif file? Is that why I am unable to plot it?

3
  • What tells you there are no values for this tif file? Some error message?
    – Spacedman
    Feb 27, 2018 at 14:49
  • @Spacedman Usually there is a values row after names that gives the min and the max pixel values, which is not here. There is no error message and I do not get a plot for the tif file when I use plot (file)
    – tg110
    Feb 27, 2018 at 14:51
  • @tg110 what does getValues(file) produce?
    – Marco
    Feb 27, 2018 at 15:03

1 Answer 1

2

Please try this to see if you get the values row:

#load raster
file<-raster('tiffname.tif')
file <- setMinMax(file)
#print raster attributes
file
2
  • 1
    Shouldn't setMinMax be applied to a RasterLayer class? so first file<-raster('tiffname.tif') and then file <- setMinMax(file)
    – Marco
    Feb 27, 2018 at 15:12
  • You are totally right. Fixed.
    – Iridium
    Feb 27, 2018 at 15:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.