[R-sig-Geo] Raster package - Focal sum in circles

Vanessa Machault vanessamachault at yahoo.com.br
Mon Jan 26 12:17:31 CET 2015


Hi,
I have a question regarding the package "raster" and the function "focal".
I have a raster with 0.5m pixels and I would like to calculate the sum of all pixels in 50m radius circles, with a moving window.I have some NA values and I need to ignore them in the calculation.
Then, I would create a new raster where all the pixels that are not NA would be filled with the sum value.
I tried with "focal" and "focal weight" but nothing comes close to the result.Example :fw <- focalWeight(x, 50, type='circle')
p_focal<-focal(x, w=fw,fun=sum , na.rm=TRUE)
I saw that several way of writing those focal stats may lead to different computation times. Here, as I need to repeat the process for a large number of rasters, computation time may be an issue.
I thank you very much in advance for your help.Regards,Vanessa Machault

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list