如何以 R 对象格式保存栅格数据? [英] How to save raster data in R object format?
问题描述
我不知道如何使用 R 中的光栅数据处理 save.image()
和 saveRDS()
.我知道光栅包打开了一个连接使用 raster()
函数处理图像文件,因此它并没有真正将文件打开到 R 工作区.
I don't know how to deal with save.image()
and saveRDS()
with raster data in R. I have understood that raster package open a connexion with the image file using raster()
function, so it doesn't really open the file into R workspace.
我想使用 save.image()
函数(或类似函数)保存我的工作区(data.frame、列表、光栅等)并在另一台计算机上打开它.如果我尝试绘制或处理保存在不同计算机中的光栅对象,总是会遇到相同的问题:
I want to save my workspace (data.frame, list, raster, etc) with save.image()
function (or similar) and open it in a different computer. If I try to plot or process a raster object saved in a different computer, always have the same issue:
Error in .local(.Object, ...) :
`C:\path\to\file.tif' does not exist in the file system,
and is not recognised as a supported dataset name.
有没有办法以 R 格式保存光栅对象(作为外部文件打开)?我指的不是 tiff 或网格等栅格格式.
Is there a way to save a raster object (opened as external file) in R format? I don't mean raster format as tiff nor grid and others.
推荐答案
您可以像其他 R 对象一样使用 save
命令保存栅格.
You can save rasters, like other R objects, using the save
command.
save(r,file="r.Rdata")
在另一台计算机上,您可以使用
On a different computer, you can load that file using
load("r.Rdata")
这将带回您工作区中的光栅 r
.
which will bring back the raster r
in your workspace.
我已经在 Windows 和 Linux 上尝试过这个,它从来没有出现问题
I have tried this across Windows and Linux and it never gives problems
这篇关于如何以 R 对象格式保存栅格数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!