Hi I am trying to read and plot on a custom shape file in R which is not a map. This is the code I use and the error I get in return:
library(rgdal)
mySHP<- choose.files()
myFile<- readOGR(mySHP)
Error in ogrListLayers(dsn = dsn) : Cannot open data source
If your file is a shapefile, you need to specify the dsn
which is the directory where is saved the shapefile and layer
which is the name of the shapefile without the extension. You cannot really do it with choose.files
. At least not that simply.
myFile <- readOGR(dsn='path.to.folder', layer='nameOfShapefile')