I cannot fortify my areacode shapefile found here.
I ran install.packages("gpclib", type = "source")
as instructed in another Stackoverflow question and get the following:
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’
I load the file by running the following lines
library("maptools")
library("ggplot2")
area <- readShapePoly("AreaCode.shp")
fort.area <- fortify(area, region = "NPA")`
When it attempts to fortify it throws the error:
Error: isTRUE(gpclibPermitStatus()) is not TRUE
I suspect it has to do with the fact that I am on a government machine and my directories are not standard, but I really need a work around.
My ultimate goal is to create a choropleth map from the shapefile with data populated by a column of phone numbers. NPA
in the shape file is the area code/region and I need to map the first three characters of the column below to that 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
I think I've gone way in over my head.
Use the rgeos package instead of gpclib
.
gpclib
is deprecated in maptools
and replaced by rgeos
, due to licensing restrictions. By default, functionality in maptools
that depended on gpclib
has been updated to utilize 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")