在ggplot2中使用fortify方法时,我遇到了以下错误:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘proj4string’ for signature ‘"NULL"’
对应的代码如下:
> library(maptools)
> gpclibPermit()
> library(ggplot2)
> library(rgdal)
> library(rgeos)
> library(ggmap)
> brMap <- readShapePoly("Google/BRASIL.shp")
> brMapDF <- fortify(brMap)
# This actually works
# But this don´t
> brMapDF <- fortify(brMap, region="UF")
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘proj4string’ for signature ‘"NULL"’
这种情况发生在我所拥有的所有shapefile文件中,因此我尝试(在上面的代码中)使用在stackoverflow格式化ggplot2地图中找到的一个shapefile文件,数据来源为https://docs.google.com/file/d/0B_coFit6AovfcEFkbHBjZEJaQ1E/edit