Ervan, You can do something like
library(raster) r <- raster(Grid2) r <- pointsToRaster(r, xy=temp[, c('x', 'y')], values=temp[,'z'], fun=max) plot(r) x <- as(r, 'SpatialGridDataFrame') On Tue, Sep 21, 2010 at 2:29 AM, Ervan Rutishauser <ervan.rutishau...@cirad.fr> wrote: > Dear all, > > I wonder if it is possible to compute a statistic (mean, max) of a > SpatialPointsDataFrame object using a SpatialGrid. > I tried it that way, but did not get what I wanted: > > # 1. Create a grid bonding the region studied > Grid<-GridTopology(c(284600,580550),c(5,5),c(600,850)) > Grid2<-SpatialGrid(Grid) > > # 2. An example of my data >> head(temp) > x y z R G B I > 1 284999.1 583538.0 9.76 11 10 8 65 > 2 284998.2 583537.1 6.40 10 4 11 69 > 3 284999.9 583536.1 28.70 8 8 4 75 > 4 284996.7 583535.9 12.55 4 3 0 63 > 5 284996.8 583533.8 7.64 16 6 10 75 > 6 284997.3 583532.5 26.46 11 9 10 74 > > coord<-coordinates(matrix(c(temp$x,temp$y),ncol=2)) > Z<- data.frame(Z=temp$z,I=temp$I) > lidar<-SpatialPointsDataFrame(coord,Z) > > test<-overlay(lidar, Para_gr) # I would like to compute the maximum of z in > each cell of the grid. > > Thank you for any help. > All the best, > Ervan > ______________________________________________________________________ > Ervan Rutishauser > CIRAD - UMR AMAP > PS1-Bd de la Lironde > 34398 Montpellier cedex 5 > phone: 04.67.61.58.00 > > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo