How to bypass permission denied error?

南笙酒味 提交于 2019-12-02 00:42:28

问题


The following example writes a point shapefile to disc. However, I get an error when the script tries to write a shapefile to C:/. I am able to write to a external hard drive though (G:/). The following is the error I receive in 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

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)

回答1:


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. Use C:/Temp/test instead.



来源:https://stackoverflow.com/questions/14115917/how-to-bypass-permission-denied-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!