I am trying to read a shapefile in R using the command:

rivnet <- readOGR(dsn = 'sa_riv_30s',layer = 'sa_riv_30s')

However, the '.shp' layer does not seem to be recognized by R. The layers present in the file directory include: shp.htm, shp.xml, .sbx, and .prj. I've tried restarting my computer, updating rgdal, using file.exist() to check and receive false. I can see it in the file directory on my computer, and I have read it in the past.

It is not just this shapefile that is not showing up. I have several shapefiles in my directory and can't read any of them in R.

  • Try using full path in dsn argument and driver = 'ESRI Shapefile'
    – aldo_tapia
    Jun 30, 2021 at 19:59
  • Have you tried the shapefile() function out of the raster package? Try something like: myshapefile <- shapefile(file.choose()) Once you hit -enter- a window should pop up allowing you to select the .shp file.
    – NewAtGis
    Jun 30, 2021 at 20:07
  • Hi @NewAtGis, thanks for the suggestions. The problem is that R does not seem to recognize that these file exists. When using the shapefile function I get: Error in .local(x, ...) : file.exists(extension(x, ".shp")) is not TRUE. The same thing seems to be happening with opening gdb. I've checked the file paths and tried using the full extension, but I'm not sure why R is not recognizing the files..
    – sharsid94
    Jun 30, 2021 at 20:17
  • I also have tried checking the permission on this folder, based on this post (gis.stackexchange.com/questions/283095/…), but it does seem like this is a system issue
    – sharsid94
    Jun 30, 2021 at 20:23

1 Answer 1


I got it to work after trying two things. I am not sure what was the cause, but the two things were:

  1. Checking permissions: R cannot read *.shp shapefile with rgdal

  2. I zipped the folder of interest. For some reason, I didn't even have to work with the zipped folder. The shapefile suddenly appeared in the uncompressed folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.