0

I have been using the following to important .shp files into R fine for ages:

require(maptools)
require(rgeos)

shp <- lapply(list.files(pattern="*.shp"), readShapePoly)

If I am loading a handful of files it works fine. However, I am trying to load in ~1000 files and I just get the (common) error message:

Error in getinfo.shape(filen) : Error opening SHP file

I have been searching online but have not been able to find a solution. The working directory is set correctly, the accompanying .dbf .shx and .prj files are present for each shapefile. Also,

list.files(getwd(),pattern="shp")

does return every file. So I'm a bit confused, am I missing something obvious?

Thanks

4

1 回答 1

1

要么改变你lapply的循环或使用options(error=recover)技巧来找出哪个文件给你带来麻烦。

不幸的是,R shapefile 函数往往对文件扩展名很挑剔。确保共同构成 shapefile 的所有不同文件的所有大小写一致。

如果你认为它是一个特定的文件,你可以使用tryortryCatch来捕捉错误。

于 2013-02-04T15:05:34.737 回答