Error: isTRUE(gpclibPermitStatus()) is not TRUE

Error: isTRUE(gpclibPermitStatus()) is not TRUE

此问题可能与 an earlier unanswered one 重复。我还有问题。

我正在尝试使用邮政编码 shapefile 并出现以下错误:

tract <- readOGR(dsn = ".", layer = "cb_2013_us_zcta510_500k")
tract<-fortify(tract, region="GEOID10")
Error: isTRUE(gpclibPermitStatus()) is not TRUE

我已尝试安装 gpclib 来解决此问题,但随后出现以下错误:

install.packages("gpclib")

Installing package into ‘C:/Users/Nick/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘gpclib’
  These will not be installed

帮忙?

我在别处了解到这个答案:我必须输入

install.packages("gpclib", type="source")

而且效果很好。

您可以在 link 之外查看 Hadley 的 master file for ggplot2/R/fortify-spatial.r. Based on this,我的理解是第 31–34 行(以当前形式)用于阅读类似

的内容
# Union together all polygons that make up a region
try_require(c("gpclib", "maptools"))
unioned <- unionSpatialPolygons(cp, invert(polys))

所以当时解决这个问题的一种方法是打开许可证

library(rgdal)
library(maptools)
if (!require(gpclib)) install.packages("gpclib", type="source")
gpclibPermit()

正如@rcs、@Edzer Pebesma 和这个 answer 提到的那样,rgeos 应该可以解决最近安装的问题。

我 运行 遇到了同样的问题,但解决方案与上面列出的略有不同。

正如其他人所提到的,问题是对 gpclib 的依赖,这是 maptools 所必需的。

但是,加载 maptools 后,它提供了以下消息...

> library('maptools')

Checking rgeos availability: FALSE
Note: when rgeos is not available, polygon geometry     computations in maptools depend on gpclib,
which has a restricted licence. It is disabled by default;
to enable gpclib, type gpclibPermit()

因此可以使用 rgeos 代替 gpclib。为了解决,我做了以下...

install.packages('rgeos', type='source')
install.packages('rgdal', type='source')

重新安装rgdal,去掉对gpclib的依赖,指向rgeos。

希望对您有所帮助。