Hello everybody. I have a set of points and I want to calculate a buffer region within a given distance from these points without using packages requiring other software (such as spgrass6). I have used function disc() for each point and then union.owin() (both from spatstat) to merge the single buffers. The result is an object of class owin, but I would need to obtain an object representing the polygons enclosing this buffer. 1) Are there smarter ways to obtain the buffer region (the union.owin is very slow when it comes to hundreds of points, as it must be applied to only two owin at a time)? It seems there isn't for buffers around polygons (as Adrian Baddeley wrote in a recent thread). 2) If not, how do I convert the owin object into a Spatial object? There are many functions doing the inverse, but I couldn't find any doing this conversion. Sorry if the questions are naive... I'm an R beginner :) Thanks, Giorgio Guzzetta
Buffer regions / owin to spatial object
3 messages · Giorgio Guzzetta, Medina, Hernan, Roger Bivand
I have a question similar to Giorgio's. I have a set of points that cover a large region that could be projected as a parallelogram including Canada, Greenland, the USA, and Mexico, as well as portions of the Artic, Atlantic and Pacific oceans and the Great Lakes. I used R and the maps and mapdata packages to obtain the set points on land with the in.polygon internal function. I would like, however, to have a buffer region of roughly 10 miles (16 km) around the coastal areas. This seems similar to what Giorgio is trying to accomplish. Hernan Medina -----Original Message----- From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Giorgio Guzzetta Sent: Tuesday, November 27, 2007 8:52 AM To: r-sig-geo at stat.math.ethz.ch Subject: [R-sig-Geo] Buffer regions / owin to spatial object Hello everybody. I have a set of points and I want to calculate a buffer region within a given distance from these points without using packages requiring other software (such as spgrass6). I have used function disc() for each point and then union.owin() (both from spatstat) to merge the single buffers. The result is an object of class owin, but I would need to obtain an object representing the polygons enclosing this buffer. 1) Are there smarter ways to obtain the buffer region (the union.owin is very slow when it comes to hundreds of points, as it must be applied to only two owin at a time)? It seems there isn't for buffers around polygons (as Adrian Baddeley wrote in a recent thread). 2) If not, how do I convert the owin object into a Spatial object? There are many functions doing the inverse, but I couldn't find any doing this conversion. Sorry if the questions are naive... I'm an R beginner :) Thanks, Giorgio Guzzetta _______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo This email is intended for the recipient only. If you are not the intended recipient please disregard, and do not use the information for any purpose.
1 day later
On Tue, 27 Nov 2007, Giorgio Guzzetta wrote:
Hello everybody. I have a set of points and I want to calculate a buffer region within a given distance from these points without using packages requiring other software (such as spgrass6). I have used function disc() for each point and then union.owin() (both from spatstat) to merge the single buffers. The result is an object of class owin, but I would need to obtain an object representing the polygons enclosing this buffer. 1) Are there smarter ways to obtain the buffer region (the union.owin is very slow when it comes to hundreds of points, as it must be applied to only two owin at a time)? It seems there isn't for buffers around polygons (as Adrian Baddeley wrote in a recent thread).
If you can move to raster, you can use erode and dilate methods for owin objects to buffer in and buffer out - these are based on "im" objects. It will not be quite the same, but the errors for moderate resolution probably will not be greater than the inaccuracies in polygon boundaries (where curves are represented as line segments). library(maptools) library(spatstat) set.seed(1) pts <- runifpoint(20) grd <- GridTopology(c(0.005, 0.005), c(0.01, 0.01), c(100, 100)) ptsi <- overlay(SpatialGrid(grd), as(pts, "SpatialPoints")) SGDF <- SpatialGridDataFrame(grd, data=data.frame(pts=rep(NA, 10000))) SGDF$pts[ptsi] <- 1 pts_im <- as(SGDF, "im") pts_owin <- as.owin(pts_im) plot(pts_owin) plot(pts, add=TRUE) pts_owin_0.03 <- dilate.owin(pts_owin, r=0.03) plot(pts_owin_0.03) plot(pts, add=TRUE) gets part of the way there, but most likely better routes exist.
2) If not, how do I convert the owin object into a Spatial object? There are many functions doing the inverse, but I couldn't find any doing this conversion.
You can get from "im" to SpatialGridDataFrame and from "ppp" fo several sp classes. So if you go with raster, you can retrieve the buffered objects. Hope this helps, Roger
Sorry if the questions are naive... I'm an R beginner :) Thanks, Giorgio Guzzetta
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at 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.Bivand at nhh.no