I don't understand why I should choose
What are all the different ways of doing this, and why should I choose one over another?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
This is explained in the documentation for maptools::readShapePoly, which you should read when asking questions of a function:
Description: The use of this function is deprecated and it is not being maintained. Use ‘rgdal::readOGR()’ or ‘sf::st_read()’ instead - both of these read the coordinate reference system from the input file, while this deprecated function does not.For writing, use ‘rgdal::writeOGR()’ or ‘sf::st_write()’ instead.
The difference between
sf::st_read is that they create very different R objects to store the information in the shapefile, and functions from one package are incompatible with data from the other.
You may also find people using
raster::shapefile to read shapefiles, this is a convenience wrapper so instead of doing
readOGR("/data/maplibrary/world","countries") you do
shapefile("/data/maplibrary/world/countries.shp") - ie you specify the path to the
.shp file in one argument and not split into folder and shapefile name.