Hi Tara, to get a mean/min/max the easiest way using your example is to use
the aggregate() function for raster objects.  Using your example after
assigning some random data to the finer grain raster, this is how I'd
accomplish what you asked:


require(raster)

ex <- (c(0, 20, 0, 20))

r.small <- raster(ncol=10, nrow=10)
extent(r.small) <- ex
r.big <- raster(ncol=200, nrow=200)
extent(r.big) <- ex

r.big[] <-  rnorm(200*200, mean=5, sd=1)

r.mean <- aggregate(r.big, fac=20, fun="mean")
r.min <- aggregate(r.big, fac=20, fun="min")
r.max <- aggregate(r.big, fac=20, fun="max")


To avoid having to know the factor by which you want to aggregate each cell
(20 in the case of your example) I would be tempted to use resample() but
the problem is that at the moment I believe it only allows you to resample
using nearest-neighbor or bilinear interopolation?  Perhaps others will
have a better solution?

Sincerely,
Forrest Stevens

Ph.D. Candidate
Department of Geography
Land Use and Environmental Change Institute
University of Florida
http://www.clas.ufl.edu/users/forrest

On Wed, Jan 4, 2012 at 2:23 PM, Tara Bridwell <tarabridwell@gmail.com>wrote:

> My overall analytical goal is to take the mean (and later min and max)
> data of a small resolution raster within the grid cells of a larger
> resolution grid.  I can do this using points via extract but can't
> seem to do it using two rasters because of the different resolutions;
> I am unable to stack or merge them.
>
> A sample:
>
> require(raster)
>
> ex <- (c(0, 20, 0, 20))
>
> r.small <- raster(ncol=10, nrow=10)
> extent(r.small) <- ex
> r.big <- raster(ncol=200, nrow=200)
> extent(r.big) <- ex
>
> What I want to be able to do is stack these two rasters, then take the
> average value of the smaller resolution grid within the larger grids.
> I am struggling to be able to do this, and would appreciate any
> thoughts.
>
> Many thanks.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

