An easy solution in 2017 is the shapefile()
function in the raster
library. Actually,as the help file says, is a "simple wrapper function around readOGR and writeOGR (rgdal package)"
#Load library
library(raster)
#Load shapefile
shp <- shapefile("myshapefile""myshapefile.shp")
UPDATE2024 UPDATE: This is stillThe raster
library has been replaced by the terra
library. You can now use the terra::vect
function to open a good option in 2019shapefile, which will create a SpatVector
object.
#Load library
library(terra)
#Load shapefile
shp <- vect("myshapefile.shp")
You can also use sf::st_read()
, which will create an sf
object.
#Load library
library(sf)
#Load shapefile
shp <- st_read("myshapefile.shp")