Drawing circular contours
On Wed, 7 Mar 2007, Edzer J. Pebesma wrote:
Gabor, sp provides a contour method for objects of class SpatialGridDataFrame. I don't know how you should create a grid such that contours are circles -- simplest to generate distances from specific points.
These are effectively vector buffers around points. My guess would be that the "circle"-type functions sent to R-help (often for drawing not returning a polygon-as-circle) could be used. For example, John Fox' posting: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/74907.html could be adapted (for the projected case, the geographical coordinates case is more difficult). Then construct SpatialPolygons objects from the output object. Or make a template polygon for (0,0) and shift to the required (x,y) centres before making SpatialPolygons objects. Hope this helps, Roger PS. Most GIS do this, and I think PostGIS/GEOS does too, but I don't think any of them can store the output as anything other than a ring polygon.
I don't know if there is easy way to do this right now; a rather indirect way is to use the kriging variance from a linear variogram and a 1-NN neighbourhood: library(gstat) # requires sp data(meuse) coordinates(meuse) = ~x+y data(meuse.grid) gridded(meuse.grid) = ~x+y # interpolate over the complete rectangular area, not just the study area: meuse.grid = as(meuse.grid, "SpatialGrid") # krige from 10 random points with linear variogram and 1-NN neighbourhood: out = krige(log(zinc)~1,meuse[sample(1:155,10),], meuse.grid, vgm(1, "Lin", 0), nmax=1) # contour kriging variance: contour(out[2], asp=1) Note that the contour method does not set the aspect ratio by default -- an omission. -- Edzer Gabor Grothendieck wrote:
I am currently doing the following to draw circles at the indicated distances from the center. The center is given by utm coordinates: utm.e, utm.n . It does work: class(im2) # "SpatialGridDataFrame" image(im2, "ind", col = col$ct) library(plotrix) dd <- c(25, 50, 100, 150) for(i in 1:4) draw.circle(utm.e, utm.n, dd[i], border = "yellow") However, I would like to do this in a style better suited to sp and rgdal by defining a function whose contours are circles and plotting the indicated contours of it. Also I assume I will get labelled contours by doing that which I don't currently have. How do I do that? I would appreciate specific code, if possible, Thanks.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________ 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