简体   繁体   English

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

[英]How to bypass permission denied error?

The following example writes a point shapefile to disc. 以下示例将点shapefile写入光盘。 However, I get an error when the script tries to write a shapefile to C:/. 但是,当脚本尝试将shapefile写入C:/时,我收到错误。 I am able to write to a external hard drive though (G:/). 我可以写入外部硬盘(G:/)。 The following is the error I receive in R: 以下是我在R中收到的错误:

Error in file(out.name, "wb") : cannot open the connection In addition: Warning message: In file(out.name, "wb") : cannot open file 'c:/test.shp': Permission denied 文件错误(out.name,“wb”):无法打开连接另外:警告消息:在文件中(out.name,“wb”):无法打开文件'c:/test.shp':权限被拒绝

How can I bypass or resolve this error? 如何绕过或解决此错误?

# 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)

Simple answer, do not write to the root-level directory of the system volume. 简单回答,不要写入系统卷的根级目录。

There are a few good reasons to create files/directories at the root of C: , but this isn't one of them. C:的根目录下创建文件/目录有几个很好的理由,但这不是其中之一。 Use C:/Temp/test instead. 请改用C:/Temp/test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM