[STATSGRASS] Extracting coordinates of contours from R

Roger Bivand Roger.Bivand at nhh.no
Tue Mar 19 17:34:07 EST 2002


On Tue, 19 Mar 2002, Bill Kristan wrote:

> Has anyone found a way to extract contours from R in a way that can be used 
> as vectors in GRASS? I want to take the contours from a kernel density 
> estimate from the package "sm" (using display="slice") and use them in GRASS. 
> As far as I know all of the contour functions in R only plot to the screen, 
> but the contours are not returned.
> 
An interesting idea! Looking at src/main/plot3d.c, it seems to be
possible, with a good deal of work. The functions do_contour() and
contour() in the C code are the ones involved, I think. I'm not sure how
to return the contours, though, probably as a list of polylines. In fact
contour() spends a lot of effort on label placement, and is quite worried
about contour polylines with too many segments.

If you felt able to look at this, I imagine that Ross Ihaka and Paul
Murrell would be interested.

> Another possible way to do this is to use R-GRASS packages kde2d.G function, 
> import the resulting raster map into GRASS and then do the contouring there. 
> However, kde2d.G gives probability densities, whereas I'm trying to get 
> contours that enclose a particular proportion of the cumulative probability. 
> I would be just as happy to do the contouring in GRASS, if anyone can give me 
> a hint about how to get cumulative probability contours.
> 
Could you set the bits of z that you don't want to NA, move the raster to
GRASS, and do it there? I'm not sure though how to get the outline to
r.thin and r.line into a vector representation.

Roger

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.




More information about the grass-stats mailing list