Aggregation of a x
will result in a Raster* object with fewer cells. The number of cells is the number of cells of x
divided by fact*fact
(when fact is a single number) or prod(fact)
(when fact consists of 2 or 3 numbers). If necessary this number is adjusted according to the value of expand
. For example, fact=2
will result in a new Raster* object with 2*2=4
times fewer cells. If two numbers are supplied, e.g., fact=c(2,3)
, the first will be used for aggregating in the horizontal direction, and the second for aggregating in the vertical direction, and the returned object will have 2*3=6
times fewer cells. Likewise, fact=c(2,3,4)
aggregates cells in groups of 2 (rows) by 3 (columns) and 4 (layers).
Aggregation starts at the upper-left end of a raster (you can use flip
if you want to start elsewhere). If a division of the number of columns or rows with factor
does not return an integer, the extent of the resulting Raster object will either be somewhat smaller or somewhat larger then the original RasterLayer. For example, if an input RasterLayer has 100 columns, and fact=12
, the output Raster object will have either 8 columns (expand=FALSE
) (using 8 x 12 = 96
of the original columns) or 9 columns (expand=TRUE
). In both cases, the maximum x coordinate of the output RasterLayer would, of course, also be adjusted.
The function fun
should take multiple numbers, and return a single number. For example mean
, modal
, min
or max
.
It should also accept a na.rm
argument (or ignore it as one of the 'dots' arguments).