Skip to content
Prev 20748 / 29559 Next

Error in function to negative buffer a SpatialPolygonsDataFrame - 'names' attribute must be the same length as the vector

Emma,

I don't know what has changed in rgeos, anyway, your current problem 
seems to be the way you assign the results of gBuffer to a list. gBuffer 
will frequently return NULL (probably the vanishing polygons), which 
removes this element from the list if you try to assign. A simplified 
example:

aa <- vector("list",10)
for (i in 1:10) {
   aa[[i]] <- NULL
   print(paste(i, length(aa)))
}
aa

You can for example try to replace the assignment with
   bb <- gBuffer(spdf[i,], width=widths[i], capStyle="ROUND")
     if (!is.null(bb)) buffs[[i]] = bb
  although you will also have to update your Filter function, as bbox 
will not work on NULL-objects.

Best wishes,
Jon
On 04-Apr-14 16:20, Brooks E.G.E. wrote: