0

To implement a choropleth, I looked back to some prompt code which I found on the Internet and read how to use the 'maptools' library to fortify a SpatialPolygonsDataFrame object. The premise that I have to make is that I installed recently R 3.6.0, also because the new version of 'sp' (necessary to make 'maptools' running correctly) requires it.

From the exploration I did, it turns out that the library 'gpclib' is not anymore available for R, and got substituted by 'rgeos'.

Now, I installed the most recent versions of 'maptools', 'rgeos' and 'rgdal', and in my code I am calling them in the sequence (for some security reasons related to my company, I had to specify a local path for the library):

library(sp) library(rgdal) library(ggplot2) library(rgeos) library(maptools)

The output for the rgeos library load looks like: "rgeos version: 0.4-3, (SVN revision 595) GEOS runtime version: 3.6.1-CAPI-1.10.1 Linking to sp version: 1.3-1 Polygon checking: TRUE "

However when I call maptools, it says: "Checking rgeos availability: FALSE Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib, which has a restricted licence. It is disabled by default; to enable gpclib, type gpclibPermit()"

So looks like maptools is not connected to rgeos. Consequently, when I try to fortify a SpatialPolygonDataFrame, I would get the error:

"Error in maptools::unionSpatialPolygons(cp, attr[, region]) : isTRUE(gpclibPermitStatus()) is not TRUE"

Then I am not understanding, neither finding related resources, how to solve this issue.

Fränzu
  • 1
  • 1
  • I suggest to look for package 'sf' which tends to modernize and encompass most features of sp, maptools, rgdal (it's OGR/vectors part) and rgeos, including alternative to gpclib in a single and consistent augmented data.frame structure. – Billy34 May 16 '19 at 08:05
  • duplicate of https://stackoverflow.com/questions/21093399/how-to-turn-gpclibpermit-to-true – Billy34 May 16 '19 at 08:16
  • Yes, true about the duplicate however in that ticket there is no solution. I tried to follow the suggestions written in the comment https://stackoverflow.com/a/35161697/9557374 but it does not work for me. – Fränzu May 16 '19 at 08:25
  • Looked this 'sf' package, installed it but still maptools could not link to rgeos, and I'm back to my original problem, without solution. QUESTION: How casting 'sf' should help to solve the issue of the link rgeos -> maptools? – Fränzu May 16 '19 at 08:26
  • It won't solve your problem with rgeos and maptools and gpclib. It's just an other way to work with spatial vector-like data using different tools. sf is able to use sp-like data structure so you can use your SpatialPolygonDataFrame and if your goal is to plot it with ggplot2 then ggplot2 will be able to plot sf-like data using `geom_sf`. So no more fortify. – Billy34 May 16 '19 at 08:40

0 Answers0