错误:isTRUE(gpclibPermitStatus())不为TRUE

gar*_*son 28 gis r choropleth

这个问题可能与早期未答复的问题重复.我还有问题.

我试图使用zipcode shapefile并出现以下错误:

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

我已经尝试安装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
Run Code Online (Sandbox Code Playgroud)

救命?

Pat*_* W. 35

您可以查看Hadley的ggplot2/R/fortify-spatial.r 的文件.根据这个外部链接,我的理解是第31-34行(当前的形式)用于阅读类似的内容

# Union together all polygons that make up a region
try_require(c("gpclib", "maptools"))
unioned <- unionSpatialPolygons(cp, invert(polys))
Run Code Online (Sandbox Code Playgroud)

那么当时解决问题的一种方法是打开许可证

library(rgdal)
library(maptools)
if (!require(gpclib)) install.packages("gpclib", type="source")
gpclibPermit()
Run Code Online (Sandbox Code Playgroud)

正如@rcs,@ Edzer Pebesma和这个答案提到的那样,rgeos应解决最近安装的问题.


小智 16

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

正如其他人所提到的,问题是依赖于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()
Run Code Online (Sandbox Code Playgroud)

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

install.packages('rgeos', type='source')
install.packages('rgdal', type='source')
Run Code Online (Sandbox Code Playgroud)

重新安装rgdal会消除对gpclib的依赖并指向rgeos.

希望这是有帮助的.


gar*_*son 6

我在别处学到了这个答案:我必须打字

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

它工作得很好。

  • 请注意,软件包 gpclib 仅可免费用于非商业用途;它的限制性许可是摆脱依赖的主要原因。 (3认同)