打开 .tiff 给我一个 plot.window() 错误

问题描述

我创建了一个栅格并将其保存为 .tif 文件。但是,当我尝试打开 .tiff 时,出现以下错误

> 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

奇怪的是,在我保存文件之前它运行良好。

我该如何管理这个错误

解决方法

没有意义

plot("20200105.tif")

您正在尝试绘制字符串 而是做

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