以下示例将点 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)