[R-sig-Geo] Generate a multi-ring buffer - Windows 8 - R 3.1.1

Wesley Roberts jwesroberts at gmail.com
Tue Feb 24 17:39:07 CET 2015


Dear R-Sig_Geo,

I would like to create a multi ring buffer around a point. I have not been
able to find a built in application to do this. So far I have been using
gBuffer with increasing widths within a for loop. Each of the individual
buffers is then stored in a list. In the past, I have merged multiple
SpatialPolygonsDataFrame's by storing each one in a list and then calling
do.call with an rbind which has worked perfectly well. Now however I
receive the following error

Error in validObject(res) :
  invalid class “SpatialPolygons” object: non-unique Polygons ID slot values


Here is some re-producible code to highlight my problem. Any help would be
greatly appreciated.

#########################################################################################################
library(rgeos)
p<-as.data.frame(matrix(741788.1,8294212,ncol=2,nrow=1))
names(p)<-c("X","Y")
coordinates(p) <- ~X+Y
projection(p)<-CRS("+proj=utm +zone=35 +south +datum=WGS84 +units=m
+no_defs")
buff.list<-list()
i=1
for (i in 1:18){
  x.1<-gBuffer(p,width=i*10)
  df<-as.data.frame(matrix(i,ncol=1,nrow=1))
  x.2<-SpatialPolygonsDataFrame(x.1, df, match.ID = FALSE)
  row.names(x.2 at data)<-i
  buff.list[i]<-x.2
  i=i+1
}
buff.out<-do.call(rbind,buff.list)
#########################################################################################################

Many thanks and kind regards,
Wesley

-- 
Wesley Roberts
jwesroberts at gmail.com
Cell: +27(0)83 5355 646
skype: roberts-w

I hear...I forget
I see...and I remember
I do...and I understand
Ancient Chinese Proverb

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list