[R-sig-Geo] Question concerning the comand unionSpatialPolygons

Roger Bivand Roger.Bivand at nhh.no
Thu Mar 31 20:21:46 CEST 2011


On Thu, 31 Mar 2011, Everton Emanuel wrote:

> Dear all,
>
> I am trying to manipulate a shape.file using the function
> unionSpatialPolygons. It is weird but the example, given by the R-CRAN, is
> not working, and I do not know how to solve the problem. Any help will be
> appreciated.

What example (from an older version of maptools than you have installed on 
your computer - what does ?unionSpatialPolygons show in its example?)? If 
you look at the example on the help page of the function for the 
unionSpatialPolygons() function, you see that for maptools 0.7-33 through 
0.7-38 it said:

gpclibPermit()
require(gpclib)

and now (0.8-6) says gpclibPermit(), which may cause gpclib to be used if 
the newly released rgeos package is not available. The gpclib package has 
a very bad license, and should be avoided where possible. If you use the 
command gpclibPermit() and do use gpclib (by not installing rgeos), you 
agree to the license terms implicitly.

The error message you report invites you to ask ?gpclibPermitStatus, and 
that help page explains what the problem is. So two solutions - update 
your maptools (it may be up-to-date, but the help page to which you are 
refering is over a year out of date) and implicitly accept the gpclib 
license, or install rgeos instead.

Roger

>
> Example given by the library maptools:
>
> library(sp)              * ## I discovered that you need to load the
> library spdep, otherwise you do not read the shape.file NorthCaroline*
>
> library(gpclib)
>
> nc1 <- readShapePoly(system.file("shapes/sids.shp",
> package="maptools")[1], proj4string=CRS("+proj=longlat +datum=NAD27"))
>
> lps <- coordinates(nc1)
>
> ID <- cut(lps[,1], quantile(lps[,1]), include.lowest=TRUE)
>
> reg4 <- unionSpatialPolygons(nc1, ID)            *## Here I get the
> following error mensage:* *"Error: isTRUE(gpclibPermitStatus()) is not
> TRUE"*
>
> sapply(slot(reg4, "polygons"), function(i) slot(i, "ID"))
>
> Everton.
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, 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