rgeos::gBuffer() fails when passed a SpatialPolygonsDataFrame containing a single multi-part @Polygons object.
Oops. The post's title should have read "rgeos::gBuffer( , byid=TRUE) fails when...". (I inadvertently left out the `byid=TRUE` bit). My apologies.
On Mon, Feb 8, 2016 at 9:59 AM, Josh O'Brien <joshmobrien at gmail.com> wrote:
Hello,
Not sure if this would be considered a bug, but it did recently bite
me (and might bite others using gBuffer(..., byid=TRUE)
programatically).
library(sp)
library(rgdal)
library(rgeos)
## Example SpatialPolygonsDataFrame
x <- readOGR(system.file("etc/shapes", package="spdep"), "sids")[c(89,28),]
plot(x, col=c('dodgerblue', 'wheat'))
## Works fine on object with multiple @Polygons in @polygons, even
## if one of the @Polygons is multi-part
gBuffer(x, width=0.01, byid=TRUE)
## Works with a single single-part @Polygons object in @polygons
gBuffer(x[1,], width=0.01, byid=TRUE)
## Fails with a single _multi-part_ @Polygons object in @polygons
gBuffer(x[2,], width=0.01, byid=TRUE)
Thanks (and please let me know an rgeos-specific note like this would
be better posted elsewhere),
Josh O'Brien