MLU0907
MLU0907

Reputation: 43

readOGR(), "cannot open file" error

Let me begin by saying that I have exhaustively looked at the other threads that have dealt with readOGR errors, and have made several attempts to implement them for my own benefit.

The issue I have is similar to questions previously addressed: that is to say that I cannot import a shapefile via readOGR.

My working directory is :

("~/Desktop/R_Thesis_Project")

Please not that I realize that this not the full working directory. I have entered that as well for the 'dns' and that produces the same result.

The shapefile (which includes the .shp, .dbf, .xml, .shx, and .prj is found in:

("~/Desktop/R_Thesis_Project/Shapefile")

Note that there is no ".shp" extension to this folder.

I have confirmed that this folder is indeed in my working directory by using:

list.files("~/Desktop/R_Thesis_Project") and

file.exists("~/Desktop/R_Thesis_Project/Shapefile")

Yet when I do the following two variations, I get the following errors:

Shapefile=readOGR("~/Desktop/R_Thesis_Project","Shapefile") Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open file

and if I try to move the Shapefile folder to a different folder in my directory (i.e. the "Data folder"), I get the following error:

Shapefile=readOGR(".","/Data/Shapefile") Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open layer

I'm not sure if it is worth mentioning that this shapefile was downloaded from a Box folder. Furthermore it has never been opened in other applications such as ArcGIS. I do not have ArcGIS on my desktop.

I've been growing incredibly frustrated that I cannot read this shapefile into R. Any and all recommendations/help is appreciated!

-Thanks in advance,

M

Upvotes: 4

Views: 6058

Answers (1)

Phoebe Matara
Phoebe Matara

Reputation: 26

Check inside the Shapefile folder if the .shp, .dbf, .xml, .shx, and .prj files are actually named as Shapefile. I did that and it helped . I hope it helps you too

Upvotes: 1

Related Questions