3

以下示例将点 shapefile 写入光盘。但是,当脚本尝试将 shapefile 写入 C:/ 时出现错误。我可以写入外部硬盘驱动器(G:/)。以下是我在 R 中收到的错误:

文件中的错误(out.name,“wb”):无法打开连接另外:警告消息:在文件中(out.name,“wb”):无法打开文件'c:/test.shp':权限被拒绝

如何绕过或解决此错误?

# available from: cran.r-project.org/web/packages/shapefiles/shapefiles.pdf
# Samples of using the convert.to.shapefile function to write out simple shapefiles
# from basic R data.frames

require(shapefiles)
require(maptools)

dd <- data.frame(Id=c(1,2),X=c(3,5),Y=c(9,6))
ddTable <- data.frame(Id=c(1,2),Name=c("Item1","Item2"))
ddShapefile <- convert.to.shapefile(dd, ddTable, "Id", 1)
write.shapefile(ddShapefile, "C:/test", arcgis=T)
shape <- readShapePoints("C:/test")
plot(shape)
4

1 回答 1

5

简单的回答,不要写入系统卷的根目录。

在 的根目录下创建文件/目录有几个很好的理由C:,但这不是其中之一。改为使用C:/Temp/test

于 2013-01-02T02:12:14.767 回答