发布强化 shapefile

Issue fortifying shapefile

我无法强化我找到的区号 shapefile here

I 运行 install.packages("gpclib", type = "source") 按照另一个 Whosebug 问题中的说明得到以下内容:

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\RtmpInWyln\downloaded_packages’

我通过 运行 以下几行

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

当它尝试强化时抛出错误:

Error: isTRUE(gpclibPermitStatus()) is not TRUE

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

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

Callers
7933959817
2575087989
3314687459
2734772497
5477907009
1129113780
6474925414
4681997266
9718681894
4875725216

sessionInfo()

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 

我想我已经过头了。

使用 rgeos 包而不是 gpclib

由于许可限制,

gpclibmaptools 中被弃用并被 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")