Skip to main content
added 419 characters in body
Source Link
Christopher
  • 900
  • 7
  • 13

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")

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")

UPDATE: This is still a good option in 2019.

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.shp")

2024 UPDATE: The raster library has been replaced by the terra library. You can now use the terra::vect function to open a shapefile, 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")

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")

UPDATE: This is still a good option in 2019.

An easy solution in 2017 is the shapefile() function in the raster library.

#Load library
library(raster)

#Load shapefile
shp <- shapefile("myshapefile")

UPDATE: This is still a good option in 2019.

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")

UPDATE: This is still a good option in 2019.

added 52 characters in body
Source Link
Christopher
  • 900
  • 7
  • 13

An easy solution in 2017 is the shapefile() function in the raster library.

#Load library
library(raster)

#Load shapefile
shp <- shapefile("myshapefile")

UPDATE: This is still a good option in 2019.

An easy solution in 2017 is the shapefile() function in the raster library.

#Load library
library(raster)

#Load shapefile
shp <- shapefile("myshapefile")

An easy solution in 2017 is the shapefile() function in the raster library.

#Load library
library(raster)

#Load shapefile
shp <- shapefile("myshapefile")

UPDATE: This is still a good option in 2019.

Source Link
Christopher
  • 900
  • 7
  • 13
Loading