[R-sig-Geo] Help with gpclib

Roger Bivand Roger.Bivand at nhh.no
Thu Jul 19 09:23:28 CEST 2012


On Thu, 19 Jul 2012, O'Hanlon, Simon J wrote:

> Can you load up the gpclib package? If not perhaps you need to reinstall 
> that?

The chief problem is the totally unnecessary use of gpclib in fortify() in 
ggplot2. gpclib should never, ever be used, as its licence only permits 
hobby use to learn about polygon clipping - imposed against the author's 
will by his former university. The rgeos package provides all 
functionality provided by gpclib except breaking polygons into component 
triangles, which is not relevant here. Specifically, 
ggplot2/R/fortify-spatial.R says (l. 33-5):

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

If you replace these with:

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

it will just work (I have not tried this, I am not a ggplot2 developer). 
The rgeos package does have an external dependency, but is available as a 
CRAN binary for Windows and OSX, so there is no reason at all for ggplot2 
to suggest gpclib rather than rgeos.

Once ggplot2 is updated, service should resume.

Hope this clarifies,

Roger


>
>
>> library(gpclib)
>
> General Polygon Clipper Library for R (version 1.5-1)
>
> Type 'class ? gpc.poly' for help
>
>
> Cheers,
>
>
> Simon
>
>
>
> --------------------------------
> Simon O'Hanlon, BSc MSc
> Department of Infectious Disease Epidemiology
> Imperial College London
> St. Mary's Hospital
> London
> W2 1PG
> ________________________________
> From: Manuel Sp?nola [mspinola10 at gmail.com]
> Sent: 19 July 2012 03:26
> To: O'Hanlon, Simon J
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Help with gpclib
>
> Thank you very much Simon,
>
> I get (I don't know why):
>
>> library(maptools)
> Loading required package: foreign
> Loading required package: sp
> Loading required package: lattice
> Checking rgeos availability: TRUE
>> library(rgdal)
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.9.0, released 2011/12/29
> Path to GDAL shared files: /Library/Frameworks/R.framework/Versions/2.15/Resources/library/rgdal/gdal
> Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
> Path to PROJ.4 shared files: /Library/Frameworks/R.framework/Versions/2.15/Resources/library/rgdal/proj
>> library(rgeos)
> Loading required package: stringr
> Loading required package: plyr
> rgeos: (SVN revision 348)
> GEOS runtime version: 3.3.3-CAPI-1.7.4
> Polygon checking: TRUE
>
>> gpclibPermitStatus()
> [1] FALSE
>> gpclibPermit()
> [1] FALSE
>
> 2012/7/18 O'Hanlon, Simon J <simon.ohanlon at imperial.ac.uk<mailto:simon.ohanlon at imperial.ac.uk>>
> Dear Manuel,
> I am also running R2.15.1 on Mac OS X 10.7.
>
> I get:
>> library(maptools)
> Loading required package: foreign
> Loading required package: sp
> Loading required package: lattice
> Checking rgeos availability: TRUE
>> library(rgdal)
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.9.0, released 2011/12/29
> Path to GDAL shared files: /Users/Simon/R64Libs/rgdal/gdal
> Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
> Path to PROJ.4 shared files: /Users/Simon/R64Libs/rgdal/proj
>> library(rgeos)
> Loading required package: stringr
> Loading required package: plyr
> rgeos: (SVN revision 348)
> GEOS runtime version: 3.3.3-CAPI-1.7.4
> Polygon checking: TRUE
>
>> gpclibPermitStatus()
> [1] FALSE
>> gpclibPermit()
> [1] TRUE
>
> Perhaps you can try updating to the latest rgeos release? And maybe try updating your rgdal from the kyngchaos website (if it isn't already the latest version)?
>
> HTH,
>
> Simon
> --------------------------------
> Simon O'Hanlon, BSc MSc
> Department of Infectious Disease Epidemiology
> Imperial College London
> St. Mary's Hospital
> London
> W2 1PG
> ________________________________________
> From: r-sig-geo-bounces at r-project.org<mailto:r-sig-geo-bounces at r-project.org> [r-sig-geo-bounces at r-project.org<mailto:r-sig-geo-bounces at r-project.org>] on behalf of Manuel Sp?nola [mspinola10 at gmail.com<mailto:mspinola10 at gmail.com>]
> Sent: 15 July 2012 16:02
> To: r-sig-geo at r-project.org<mailto:r-sig-geo at r-project.org>
> Subject: [R-sig-Geo] Help with gpclib
>
> Dear list members,
>
> I am running R 2.15.1 on a MAC OSX 10.7.
>
> I receive an error message regarding gpclib (see below):
>
>> library(rgdal)
>> library(maptools)
>> library(rgeos)
> Loading required package: stringr
> rgeos: (SVN revision 330)
> GEOS runtime version: 3.3.2-CAPI-1.7.2
> Polygon checking: TRUE
> WARNING! if you turn polygon checking off, and polygons are
> not valid in GEOS, you risk losing data as your R session may crash!
>
>> indice <- readOGR(".", "indicesalud2007crtm")
> OGR data source with driver: ESRI Shapefile
> Source: ".", layer: "indicesalud2007crtm"
> with 82 features and 27 fields
> Feature type: wkbPolygon with 2 dimensions
>
>> map <- fortify(indice)
> Using NCANTON to define regions.
> Error: gpclib, maptools package required for this functionality.  Please
> install and try again.
>
>> gpclibPermit()
> [1] FALSE
>
> Best,
>
> Manuel
>
>
> --
> *Manuel Sp?nola, Ph.D.*
> Instituto Internacional en Conservaci?n y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola at una.ac.cr<mailto:mspinola at una.ac.cr>
> mspinola10 at gmail.com<mailto:mspinola10 at gmail.com>
> Tel?fono: (506) 2277-3598
> Fax: (506) 2237-7036
> Personal website: Lobito de r?o <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>
>        [[alternative HTML version deleted]]
>
>
>
>
> --
> Manuel Sp?nola, Ph.D.
> Instituto Internacional en Conservaci?n y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola at una.ac.cr<mailto:mspinola at una.ac.cr>
> mspinola10 at gmail.com<mailto:mspinola10 at gmail.com>
> Tel?fono: (506) 2277-3598
> Fax: (506) 2237-7036
> Personal website: Lobito de r?o<https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS<http://www.icomvis.una.ac.cr/>
>
> 	[[alternative HTML version deleted]]
>
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list