5

我在一个脚本中遇到错误,该脚本迭代目录中的一些文本文件,进行一些数据操作并使用 R 中 rgdal 包中的 writeOGR 写入 ESRI shapefile。在一定数量的文件之后,我不断收到错误被写入(似乎是大约 43-44 个单独的文件,或大约 14 个完整的 shapefile,因为每个 shapefile 创建了许多文件)。

错误通常类似于

GDAL Error 4: Unable to open ./test_8.shp or ./test_8.SHP

此外,脚本崩溃后,我收到一个错误,例如

 cannot open file 'file_test.R': Too many open files

当我尝试读取另一个文件或做任何事情时。

showConnections

此时不显示任何打开的文件。

这是一些重现问题的代码:

library(gstat)
library(rgdal)
data(meuse)

coordinates(meuse) = ~x + y

for (i in 1:50){
    writeOGR(meuse,'.',paste('test',i,sep="_"),driver="ESRI Shapefile")
}

我在 OSX 上使用 R 2.12.2。错误发生在 64 位和 32 位版本上。

4

1 回答 1

4

您的代码在 Ubuntu 11.04 和 R 2.13 上为我工作,可能也值得writeSpatialShapemaptools包中尝试。

于 2011-06-02T20:20:04.507 回答