[R-sig-Geo] Speeding up focal

Kenny Bell kmb56 at berkeley.edu
Sat Mar 19 06:24:58 CET 2016


I am trying to use raster::focal to fill some holes in many RasterLayers. I
call:

focal(raster_layer, fun = mean, w = matrix(1, nrow = 3, ncol = 3), NAonly =
TRUE, na.rm = TRUE)

I am only interested in filling in holes in a small subset of each
RasterLayer (i.e. a country when the raster is global). focal spends a lot
of time trying to fill in the oceans and holes in other countries.

Is there any way to get focal to only change values for some specific
subset of a RasterLayer?

Thanks so much!
Kenny

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list