[R-sig-Geo] raster package and "?focal" FUN

Alexander Brenning brenning at uwaterloo.ca
Mon Apr 6 17:53:28 CEST 2009


Hi,

I haven't used the focal function in raster, which should be able to do 
this, but in the RSAGA package there is a function called focal.function 
that does the same thing on ASCII grids. In your case this should work:

focal.function("dem",fun="max",radius=3,mw.to.vector=TRUE,mw.na.rm=TRUE)

or just

gapply("dem", "max", radius = 3)

Have a look at ?focal.function - there are examples on how to use 
customized focal functions.

I hope this helps
   Alex


gianni lavaredo wrote:
>  I am seeing RASTER  package and "focal". I have a raster ascii grid format
> with a Z value. I am trying to do a mobile window with a specific radius
> (es: 10 m) to find the pixel with the max value of Z inside the window. I
> need to do this operation for each pixel and save a a new grid with only the
> max value pixel.
> I wish to study a specific function or package for to do this but the R
> world is very huge...
> 
> 
> es: mobile window 10 m
> pixelmax <- value
> NO pixelmax <- 0
> 
> thanks
> Gianni
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 

-- 
Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1
http://www.fes.uwaterloo.ca/geography/faculty/brenning/



More information about the R-sig-Geo mailing list