Hi Renaud,
Take a look at the pointsToRaster() function in the raster package.
cheers,
Paul
Renaud Lancelot wrote:
Dear all,
I have two nested grids (SpatialGridDataFrame) looking like this:
prj - +proj=utm +zone=28 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
gt1 - GridTopology(c(5, 5),
Hi
I guess you could also try something like:
# First of all
showMethods(overlay)
# Than, one possibility:
ovrl - overlay(as(sgdf2, SpatialPixelsDataFrame),
as(sgdf1, SpatialPointsDataFrame))
# aggregate by the ovrl index
aggMean - aggregate(slot(sgdf1, data),
Renaud,
Here another way:
library(raster)
r - raster(sgdf1, 1)
ra - aggregate(r, 10, mean)
sgdf3 - as(ra, 'SpatialGridDataFrame')
values(ra)
[1] 0.43 0.45 0.57 0.50 0.49 0.47 0.58 0.50 0.61 0.49 0.49 0.53 0.54
0.51 0.53 0.42 0.48 0.51 0.54 0.53 0.50
[22] 0.52 0.39 0.52 0.52 0.62 0.53 0.48
Thank you for the different solutions which all work fine.
Kind regards,
Renaud
2009/12/22, Robert J. Hijmans r.hijm...@gmail.com:
Renaud,
Here another way:
library(raster)
r - raster(sgdf1, 1)
ra - aggregate(r, 10, mean)
sgdf3 - as(ra, 'SpatialGridDataFrame')
values(ra)
[1] 0.43