Search code examples
rrstudior-maptools

Error opening SHP file in Rstudio


I am using maptools to open a shapefile in R, but I get the following error in Rstudio:

library(maptools)
basins = readShapeSpatial("H:GIS/shapefiles/basins")
Error in getinfo.shape(fn) : Error opening SHP file

When I try the exact same code in RGui (instead of Rstudio) it works! I would like to keep using Rstudio as it is so convenient so anybody know how to fix this problem?

Thanks!


Solution

  • I can't answer as to why it works in Rstudio, but the issue is that your drive path / drive name is non-standard

     'H:/GIS/shapefiles/basins'
    

    is more standard, and works in both.