gpt4 book ai didi

r - 在 R 中使用 writeOGR 写入 shapefile 时出现问题

转载 作者:行者123 更新时间:2023-12-02 03:01:31 28 4
gpt4 key购买 nike

我在一个脚本中遇到错误,该脚本迭代目录中的一些文本文件,进行一些数据操作并使用 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 位版本都会出现错误。

最佳答案

您的代码在 Ubuntu 11.04 和 R 2.13 上对我有用,可能也值得尝试 maptools 包中的 writeSpatialShape

关于r - 在 R 中使用 writeOGR 写入 shapefile 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6219368/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com