Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R工具中读取.shp文件_R - Fatal编程技术网

如何在R工具中读取.shp文件

如何在R工具中读取.shp文件,r,R,我想使用以下脚本从R工具读取.shp文件: >scot_LL<-readOGR("C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot/scot.shp","scot"), >文件中出现错误(粘贴(DSN,.Platform$file.sep,layer,.dbf,.sep=”“),: 无法打开连接: 此外:警告消息:: 在文件中(粘贴(DSN,.Platform$file.sep,layer,.db

我想使用以下脚本从R工具读取.shp文件:

>scot_LL<-readOGR("C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot/scot.shp","scot"),
>文件中出现错误(粘贴(DSN,.Platform$file.sep,layer,.dbf,.sep=”“),
: 无法打开连接
: 此外:警告消息:
: 在文件中(粘贴(DSN,.Platform$file.sep,layer,.dbf,.sep=”“),:
: 无法打开文件“C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot/Scot.dbf”:没有这样的文件或目录

您能帮助我吗。

这里有一个使用
maptools
软件包的解决方案:

library(maptools)

scot_mp <- readShapeSpatial('C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot/scot.shp')

proj4string(scot_mp) <- "+proj=longlat +datum=WGS84" # specify projection

plot(scot_mp)
scot_mp <- readOGR('C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot', 'scot')
第一个参数不必包含形状文件的名称,但主要问题似乎是至少
dbf
文件不在您的文件夹中,所有这些都是必需的,并且应该在同一文件夹中:
scot.shp,scot.dbf,scot.shx
。然后,它将作为另一个解决方案继续进行:

proj4string(scot_mp) <- "+proj=longlat +datum=WGS84"
plot(scot_mp)

proj4string(scot\u mp)下面是一个使用
maptools
包的解决方案:

library(maptools)

scot_mp <- readShapeSpatial('C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot/scot.shp')

proj4string(scot_mp) <- "+proj=longlat +datum=WGS84" # specify projection

plot(scot_mp)
scot_mp <- readOGR('C:/Documents and Settings/Admin/Desktop/scotlip/lip cancer/New Scot', 'scot')
第一个参数不必包含形状文件的名称,但主要问题似乎是至少
dbf
文件不在您的文件夹中,所有这些都是必需的,并且应该在同一文件夹中:
scot.shp,scot.dbf,scot.shx
。然后,它将作为另一个解决方案继续进行:

proj4string(scot_mp) <- "+proj=longlat +datum=WGS84"
plot(scot_mp)

proj4string(scot\u mp)>getinfo.shape(fn)中的scot\u mp错误:打开SHP时出错file@vinoradha我猜其他两个文件(
scot.dbf,scot.shx
)不在您的文件夹中。>getinfo.shape中的scot\u mp错误(fn):打开SHP时出错file@vinoradha我猜另外两个文件(
scot.dbf,scot.shx
)不在您的文件夹中。