如何在R中加载.tif光栅文件

时间:2019-04-23 15:38:19

标签: r tiff magic-numbers

我目前正在处理某些栅格模型。我的代码生成了大约4k模型(所有.tif文件),但是其中的10%无法使用load("insert path")打开。我尝试了readr()readRDS()source(),但都没有用。我也重新运行了一些模型,但没有解决问题。为什么无法加载我的.tif文件?

  

load(“ comparison / mc45bi50 / ni1130region33.tif”)   加载错误(“ comparison / mc45bi50 / ni1130region33.tif”):     恢复文件的幻数编号错误(文件可能已损坏)-未加载任何数据   另外:警告消息:   文件“ ni1130region33.tif”的魔术编号为“ II *”     不建议使用2之前的保存版本   来源(“ comparison / mc45bi50 / ni1130region33.tif”)   来源错误(“ comparison / mc45bi50 / ni1130region33.tif”):     比较/mc45bi50/ni1130region33.tif:2:0:输入意外结束   1:II *

1 个答案:

答案 0 :(得分:1)

您应该使用select id,username from users where id in ( select user_id from user_code where code in ( select code from user_code where user_id = ( select id from user where username = 'sathis'))) 库。它具有raster函数,该函数应读取您的.tif文件。

例如,自己创建一个栅格并将其保存在磁盘上,然后尝试阅读:

raster()