Gavin,
I am not sure if it is better, but you can try raster::rasterize
To coerce a SpatialGrid* to a RasterLayer you can use as(x, 'RasterLayer')
  (and vice versa)
Robert

On Mon, May 28, 2012 at 2:00 PM, Gavin Simpson <gavin.simpson@ucl.ac.uk>wrote:

> Dear List,
>
> I have a SpatialGrid object - a regular 5km by 5km over the entire land
> mass of Great Britain & NI - and a SpatialPointsDataFrame containing a
> @data slot with several attributes.
>
> I want to identify which points are in each grid cell and average the
> values of the individual attributes from the points within each cell.
> Not all cells will contain a point (for those an `NA` returned value is
> fine) though some cells will contain many points. Later I may wish to
> calculate some other summary (min or max) rather than mean.
>
> If I understand correctly, this gives the desired result:
>
> aggregate(fabResults.sp, by = frameGrid, FUN = mean)
>
> where `fabResults.sp` is my SpatialPointsDataFrame and `frameGrid` is my
> Spatial Grid. This takes a while to compute however.
>
> I was unable to come up with an `over()` call that worked.
>
> Have I got the `aggregate()` step right? Is there a way to use `over()`
> to do the same operation? Am I missing a better alternative?
>
> Thanks in advance,
>
> Gavin
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

