1

I don't understand why I should choose readOGR() over readShapePoly.

What are all the different ways of doing this, and why should I choose one over another?

closed as too broad by Simbamangu, Fran Raga, LaughU, whyzar, Hornbydd May 6 at 21:36

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Could you edit your question and describe what you have tried so far, and what your needs for shapefiles are? – Simbamangu May 4 at 16:06
  • If you read the help file for R is says readShapePoly is deprecated and don't use, use readOGR(), so I think your question is obsolete. – Hornbydd May 6 at 21:36
3

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 rgdal::readOGR and 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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.