Error opening SHP file in R using maptools readShapePoly

后端 未结 7 2027
别那么骄傲
别那么骄傲 2021-01-01 16:53

I am new to R and was following the following tutorial on the ggplot2 package found here. However the readShapePoly() function throws an error whenever I try to load the bas

7条回答
  •  Happy的楠姐
    2021-01-01 17:23

    Forget ggplot and gpcclib. Stick to maptools and rgdal that actually provide tools for reading a shapefile.

    Don't just say you've tried "this and that", outline the details. For example, does `file.exists("london_sport.shp") return TRUE?

    Also, what makes you think readShapePoly() is the right function? It only knows how to read polygon shapefiles, try readShapePoints() and readShapeLines() as well.

    If you can, try readOGR which can read a shapefile despite many caveats (including the geometry type).

    library(rgdal)
    readOGR("~/Documents/R Projects/Intro to ggplot2", "london_sport")
    

    If you can report on all of those things it's likely someone could help.

提交回复
热议问题