1

我无法强化在此处找到的区号 shapefile 。

install.packages("gpclib", type = "source")按照另一个 Stackoverflow 问题中的说明运行并得到以下信息:

trying URL 'https://cran.rstudio.com/src/contrib/gpclib_1.5-5.tar.gz'
Content type 'application/x-gzip' length 41980 bytes (40 KB)
downloaded 40 KB

'\\cdc.gov\private\M325\wol1'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'gpclib' ...
** package 'gpclib' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
gcc -m32 -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG         -I"d:/RCompile/r-compiling/local/local323/include"     -O3 -Wall  -std=gnu99     -mtune=core2 -c Rgpc.c -o Rgpc.o
gcc -m32 -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG         -I"d:/RCompile/r-compiling/local/local323/include"     -O3 -Wall  -std=gnu99     -mtune=core2 -c gpc.c -o gpc.o
gcc -m32 -shared -s -static-libgcc -o gpclib.dll tmp.def Rgpc.o gpc.o     -Ld:/RCompile/r-compiling/local/local323/lib/i386     -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.3/bin/i386     -lR
installing to C:/Program Files/R/R-3.2.3/library/gpclib/libs/i386

*** arch - x64
gcc -m64 -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG         -I"d:/RCompile/r-compiling/local/local323/include"     -O2 -Wall  -std=gnu99     -mtune=core2 -c Rgpc.c -o Rgpc.o
gcc -m64 -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG         -I"d:/RCompile/r-compiling/local/local323/include"     -O2 -Wall  -std=gnu99     -mtune=core2 -c gpc.c -o gpc.o
gcc -m64 -shared -s -static-libgcc -o gpclib.dll tmp.def Rgpc.o gpc.o     -Ld:/RCompile/r-compiling/local/local323/lib/x64     -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.3/bin/x64     -lR
installing to C:/Program Files/R/R-3.2.3/library/gpclib/libs/x64
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (gpclib)

The downloaded source packages are in
    ‘C:\Users\wol1\AppData\Local\Temp\1\RtmpInWyln\downloaded_packages’

我通过运行以下行来加载文件

library("maptools")
library("ggplot2")
area <- readShapePoly("AreaCode.shp")
fort.area <- fortify(area, region = "NPA")`

当它试图强化它时会抛出错误:

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

我怀疑这与我在政府机器上并且我的目录不是标准的事实有关,但我真的需要解决这个问题。

我的最终目标是从 shapefile 创建一个等值线图,其中的数据由一列电话号码填充。NPA形状文件中是区号/区域,我需要将下面列的前三个字符映射到该区域。

Callers
7933959817
2575087989
3314687459
2734772497
5477907009
1129113780
6474925414
4681997266
9718681894
4875725216

会话信息()

R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United     States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United     States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgeos_0.3-19    ggplot2_2.1.0   maptools_0.8-39 sp_1.2-3       

loaded via a namespace (and not attached):
 [1] colorspace_1.2-6 scales_0.4.0     plyr_1.8.4       tools_3.2.3          foreign_0.8-66   gtable_0.2.0    
 [7] Rcpp_0.12.6      grid_3.2.3       munsell_0.4.3    lattice_0.20-33 

我想我已经过头了。

4

1 回答 1

1

使用rgeos包而不是gpclib.

gpclib由于许可限制,已在 中弃用maptools并替换为。rgeos默认情况下,maptools依赖的功能gpclib已更新为使用rgeos.

R> install.packages("rgeos")
R> library("maptools")
Loading required package: sp
Checking rgeos availability: TRUE
R> library("ggplot2")
R> area = readShapePoly("AreaCode.shp")    
R> fort.area <- fortify(area, region = "NPA")
于 2016-08-04T19:55:16.953 回答