# [R-sig-Geo] Drawing circular contours

Gabor Grothendieck ggrothendieck at gmail.com
Wed Mar 7 13:22:36 CET 2007

```Thanks to you and to Roger for the code.

On 3/7/07, Edzer J. Pebesma <e.pebesma at geo.uu.nl> 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. 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
> >
>
>

```