Here is another way to compute buffered polygons around points:

## One record (point) at a time (buffer of 25m radius)
> temp
        x        y
1 -300358 748992.6

library(spatstat)
discbuff<-disc(radius=25, centre=c(temp$x, temp$y))

library(sp)
polybuff<-SpatialPolygons(list(Polygons(list(Polygon(rbind(cbind(discbuff$bdry[[1]]$x,
y=discbuff$bdry[[1]]$y), c(discbuff$bdry[[1]]$x[1],
y=discbuff$bdry[[1]]$y[1])))), ID=row.names(temp))))
plot(polybuff)
points(temp, col="red")

## Numerous records (points) at once (buffer of 25m radius)
> temp
           x        y
1  -300358.0 748992.6
7  -300450.8 748764.8
13 -300415.1 748865.8
19 -300504.5 748698.4
25 -300488.4 748460.1

polys<-list()
for(i in 1:nrow(temp)) {
  discbuff<-disc(radius=25, centre=c(temp$x[i], temp$y[i]))
     discpoly<-Polygon(rbind(cbind(discbuff$bdry[[1]]$x,
y=discbuff$bdry[[1]]$y), c(discbuff$bdry[[1]]$x[1],
y=discbuff$bdry[[1]]$y[1])))
     polys<-c(polys, discpoly)
}

spolys<-list()
for(i in 1:length(polys)) {
  spolybuff<-Polygons(list(polys[[i]]), ID=row.names(temp)[i])
  spolys<-c(spolys, spolybuff)
}

polybuffs<-SpatialPolygons(spolys)

plot(polybuffs)
points(temp, col="red")

Tyler

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to