Stephane, have you tried how well this scales to, say, 1000x1000
matrices? Indeed, most basic raster GIS functionality is not available
in R packages, and would be welcome. R code is efficient for small
problems, but for cases like this scales badly as Marius noted.
We are actually working on an interface from R to the functionality of
PCRaster (http://pcraster.geog.uu.nl -- yet another raster GIS), and
expect to have this working within a few months. PCRaster is not open
source, so it is unlikely to become a CRAN package straight away, but
still it may fill a need.
This all depends on availability of sp, the long awaited package with