Skip to content

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

4 messages · Brooks E.G.E., Jon Olav Skoien, Philippi, Tom +1 more

#
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:

  
    
2 days later
#
Very interesting link to the negative buffering thread.

FYI sessionInfo:
R version 3.0.3 (2014-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
other attached packages:
[1] rgeos_0.3-4   raster_2.2-31 rgdal_0.8-16  sp_1.0-14

However you're absolutely right - now gBuffer has been updated to remove
NULL geometries I was just confusing matters by effectively trying to do the
same thing twice. 



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Error-in-function-to-negative-buffer-a-SpatialPolygonsDataFrame-names-attribute-must-be-the-same-lenr-tp7586124p7586142.html
Sent from the R-sig-geo mailing list archive at Nabble.com.