Skip to content
Prev 15664 / 29559 Next

Help with gpclib

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

            
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