[R] floodfill with matrix data

Roger Bivand Roger.Bivand at nhh.no
Mon Aug 25 18:22:48 CEST 2003


On Mon, 25 Aug 2003, Thomas Petzoldt wrote:

> Barry Rowlingson wrote:
> 
> > Howabout this i just bashed up from a quick search:
> > 
> >  boundaryFill <- function(mat, x,y,fill,boundary)
> 
> [...]
> 
> >  note it fills 4-connected regions. I wouldnt like to do it on anything 
> > complex since it'll be awful slow....
> 
> Yes, this is in principle the same solution I use during aan external C 
> function. However, the problem is not only speed, but the large amount 
> of stack memory with larger matrices (say 100 x 100) due to recursion, 
> no matter if I use options(expression = large_value) or not.
> 

A very powerful tool is grdmask in GMT (http://gmt.soest.hawaii.edu/) 
followed by grd2xyz to create something easier to read (possibly as binary 
through connections). It is well-proven, and handles large grids 
comfortably.


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




More information about the R-help mailing list