如何绕过权限被拒绝错误?

2023-11-30

以下示例将点形状文件写入光盘。但是,当脚本尝试将 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)

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何绕过权限被拒绝错误? 的相关文章

随机推荐