dimanche 20 août 2017

read files with pattern in R, error

I have a file in my directory with multiple shapefiles (about 2000) and I want to read them in R. So far I have tried the following :

list.files("my_directory",pattern=".shp")
list_here=list.files("my_directory",pattern=".shp")
for (i in 1:length(list_here)){
  bi[[i]]=readShapeSpatial(list_here[i])
  proj4string(bi[[i]])= CRS("+proj=longlat +datum=WGS84 +no_defs")
}

but I get the error Error in getinfo.shape(fn) : Error opening SHP file

each shapefile consists of .dbf,.prj,.shp,.shx files. When I try to read one or two of them I have no problem but when I try to read them in list I get the aforementioned error.

Can anyone help me?

Aucun commentaire:

Enregistrer un commentaire