On Wed, 17 Feb 2010, Tyler Dean Rudolph wrote:

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))

Note that from here you can use the coerce method in maptools:

polybuff <- as(discbuff, "SpatialPolygons")

There are many coercion methods in maptools for sp and spatstat classes.

Hope this simplifies!

Roger


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


--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
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