[R-sig-Geo] Buffer series
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Tue Jul 12 12:53:44 CEST 2011
On Tue, Jul 12, 2011 at 11:00 AM, te_är <tamara_em at hotmail.com> wrote:
> I'd like to automatically create buffers to points with a series of different
> radii.
> I'd intuitively tried like that (but I realized while writing that it cannot
> work):
>
> for (i in 1:10)
> {
> west_buf[i]<-gBuffer(west,byid=T,id=NULL,width=i,capStyle="ROUND")
> cent_buf[i]<-gBuffer(cent,byid=T,id=NULL,width=i,capStyle="ROUND")
> east_buf[i]<-gBuffer(east,byid=T,id=NULL,width=i,capStyle="ROUND")
> }
What makes you think it cannot work? I think your only problem here
is storing the result in a vector rather than a list.
> Is there a possibility to create a series of buffers of different size, i.e.
> kind of
> looping the width?
Like this:
> pts=cbind(runif(10),runif(10))
> pts=SpatialPoints(pts)
> plot(pts)
> bufs=list() # store results as elements of a list
> for(i in 1:10){bufs[[i]]=gBuffer(pts,byid=TRUE,id=NULL,width=i/10,capStyle="ROUND")}
> plot(bufs[[10]])
> plot(bufs[[9]],add=TRUE,lty=2)
You can store almost anything in a list.
Barry
More information about the R-sig-Geo
mailing list