Hi Tyler, Your example would have been more easily reproducible if it had started with something like:
temp = list(x=-300358, y=748992.6, X2=-300450.8, Y2=748764.8) library(spatstat) ... library(maptools) union = unionSpatialPolygons(polybuffs, ID=rep(1, times=length(polybu...@polygons)) ) plot(union) # then perhaps: library(raster) polygonValues(union, raster) Robert On Wed, Feb 17, 2010 at 10:17 AM, Tyler Dean Rudolph <tylerdeanrudo...@gmail.com> wrote: > I've been attempting for many moons to develop a function which will allow > me to place a buffer of adjustable radius around an animal's movement > trajectory with which I may extract underlying pixel values from a raster of > environmental data. I would like to be able to extract the habitat values > using read functions in the raster package as I have tens of thousands of > observations (trajectories) and importing or cropping images is much too > demanding on time and processing. > > One fairly intuitive solution is to create circular buffers around points > along each trajectory, thus creating the buffered trajectory with which I > can interpolate the raster values. This is fairly simple and looks good: > >> temp > x y X2 Y2 > 1 -300358 748992.6 -300450.8 748764.8 > > xran<-range(c(temp$x, temp$X)-500, c(temp$x, temp$X)+500) > yran<-range(c(temp$y, temp$Y)-500, c(temp$y, temp$Y)+500) > subwin<-owin(xrange=xran, yrange=yran) > traj<-pointsOnLines(psp(temp$x, temp$y, temp$X, temp$Y, subwin), eps=12) > polys<-list() > for(i in 1:length(traj$x)) { > discbuff<-disc(radius=25, centre=c(traj$x[i], traj$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)) { > polybuff<-Polygons(list(polys[[i]]), ID=i) > spolys<-c(spolys, polybuff) > } > polybuffs<-SpatialPolygons(spolys) > > plot(polybuffs) > > ...but is there a way now to merge all these circles into one polygon? I'm > afraid I haven't found it yet yet. > > Likewise if there are other methods folks can suggest that would accomplish > the same goal I am all ears. > > 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 > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo