如何更改临时文件的目录 - 巨大临时光栅文件的问题 [英] How to change directory for temporary files - problems with huge temporary raster files

查看:45
本文介绍了如何更改临时文件的目录 - 巨大临时光栅文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在拼命尝试 writeRaster() 但是,由于光栅非常大,我需要大量的临时内存.我的 C:/ 驱动器上的空间有限,因此我想将临时目录更改为 D:/TEMP/.我尝试了在 Internet 上找到的不同方法,例如:

I'm desperately trying to writeRaster() but, since the raster is quite large I need a lot of temp memory. The space on my C:/ drive is limited and therefore I want to change the temporary dir to D:/TEMP/. I tried different approaches I found on the Internet like:

更改临时目录

http://r.789695.n4.nabble.com/How-do-I-set-the-Windows-temporary-directory-in-R-td876483.html

等等.

rasterOptions(tmpdir = "D:/RTEMP/") 没有解决问题.即使它在计算栅格时起作用,它也不会影响writeRaster() 函数.

rasterOptions(tmpdir = "D:/RTEMP/") didn't solve the problem. Even if it worked while the calculation of the raster, it doesn't affect the writeRaster() function.

如果有人能帮助我,我将不胜感激.

I would be very thankful, if anybody can help me.

这是我的sessionInfo():

`R version 3.1.2 (2014-10-31)

Platform: x86_64-w64-mingw32/x64 (64-bit)`

推荐答案

我得到了正确答案:

 write("TMPDIR = D:/rtmp/", file=file.path(Sys.getenv('TMPDIR'), '.Renviron'))
 write("R_USER = D:/rtmp/", file=file.path(Sys.getenv('R_USER'), '.Renviron'))

这甚至会改变 writeRaster() 函数的临时目录

This changes even the temp-directory of the writeRaster() function

更新:

对于那些可能遇到此错误的人(由于权限有限)

for those of you, who might have trouble with this error (due to limited permissions)

> write("TMPDIR = D:/rtmp/", file=file.path(Sys.getenv('TMPDIR'), '.Renviron'))
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file '/.Renviron': Permission denied

我发现

rasterOptions(tmpdir = "D:/rtmp/")
write("R_USER = D:/rtmp/", file=file.path(Sys.getenv('R_USER'), '.Renviron'))

也解决了这个问题.

这篇关于如何更改临时文件的目录 - 巨大临时光栅文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆