Search code examples
rplotrasterspatialgeotiff

Opening .tiff gives me a plot.window() error


I created a raster and saved it as a .tif file. However, when I tried to open the .tiff, I get the following error:

> plot("20200105.tif")
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

The strange thing is, before I saved the file it worked fine.

How do I manage this error?


Solution

  • This make no sense

    plot("20200105.tif")
    

    You are trying to plot a character string Instead do

    library(raster)
    r <- raster("20200105.tif")
    # or
    # b <- brick("20200105.tif")
    plot(r)