【发布时间】:2020-04-16 23:52:21
【问题描述】:
我在 R 中做一些空间方面的工作,我的一些代码将不再在我使用多年的计算机上运行,特别是因为它“内存不足”。
## Raster going in
xx <- raster(fatNames[[i]])
xx
class : RasterLayer
dimensions : 5160, 14436, 74489760 (nrow, ncol, ncell)
resolution : 0.008333333, 0.008333333 (x, y)
extent : -172.3, -52, 23.5, 66.5 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : D:\Dropbox\wintor_aux\Results\myluFatReq_100_2_fat.inf.tif
names : myluFatReq_100_2_fat.inf
values : 0.1831425, 3.449095 (min, max)
## transform
x.rast <- projectRaster(xx,crs = CRS("+init=epsg:2955"))
错误:不能满足 4.2Gb 的向量。
现在我知道这是一个大小合适的光栅(输入光栅大小:75.5 MB),但是机器有 32Gb 的 RAM,没有其他程序在运行,我仍然占用内存。多年来,我已经做过数百次这样的事情,据我所知,自从我在大约一个月前最后一次这样做以来,机器上的任何东西都没有改变。
我已经尝试重新启动会话,重新启动计算机并用谷歌搜索了一下,但我仍然没有任何运气来尝试追查问题。当我在具有 1/2 RAM 的机器上尝试相同的代码块时,我可以毫无问题地运行它(最大使用 ~ 8Gb ram)。有没有人对我如何追究这个问题有任何建议?
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252
[3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C
[5] LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] raster_2.6-7 rgdal_1.3-3 sp_1.3-1 sf_0.6-3
[5] RevoUtils_11.0.1 RevoUtilsMath_11.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 lattice_0.20-35 class_7.3-14 grid_3.5.1 spData_0.2.9.0
[6] DBI_1.0.0 magrittr_1.5 e1071_1.7-0 units_0.6-0 tools_3.5.1
[11] yaml_2.2.0 compiler_3.5.1 classInt_0.2-3
【问题讨论】:
标签: r out-of-memory rstudio r-raster