You can try one of the 'focal' functions of the raster package on R-Forge. Not particularly fast either, but probably much faster that what you have now. Robert
On Thu, Jan 28, 2010 at 11:16 PM, Pierre Roudier <pierre.roud...@gmail.com> wrote: > Dear list, > > I am processing gridded data like DEMs, imported in R from geotiff > files. Of course, such data is regularly gridded, but very often with > NA values. In the framwork of some tests, I have to generate a > neighbourhood of the DEM, so that to extract local extrema of the > layer. For this task, I wrote a function based on the knearneig() > function from the spdep package, with k=4 or k=8, to generate and > analyse the neighbourhood of each point. > > Unfortunately, I often have to process big datasets (let's say grids > with between 50,000 and 350,000 points), and that's working but > knearneigh() takes *hours* to process. > > Does anybody would have any suggestion to improve the efficiency of this step > ? > > Thanks, > > Pierre > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo