[R-sig-Geo] over() in sp package

2015-04-13 Thread Kenny Bell
Hi, When I call: over(spPolyDf, spGridDf) The function seems to be returning the spGridDf$band1 value for the first grid cell that is contained in each polygon. What I would like is an overlap-area weighted average (or some provided function like sum) of all the grid cells contained (or partial

Re: [R-sig-Geo] over() in sp package

2015-04-13 Thread Robert J. Hijmans
Kenny, Here is an alternative route library(raster) states <- shapefile("cb_2013_us_state_20m.shp") tMaxGrid <- raster(unzippedFiles[1]) x <- extract(tMaxGrid, states) This returns a list of the length of states. Each list element has a vector with the grid cell values. For a mean do xs <- ext

Re: [R-sig-Geo] over() in sp package

2015-04-13 Thread Edzer Pebesma
On 04/14/2015 01:27 AM, Kenny Bell wrote: > Hi, > > When I call: > > over(spPolyDf, spGridDf) > > The function seems to be returning the spGridDf$band1 value for the first > grid cell that is contained in each polygon. This is documented; you can use returnList = TRUE to get the list of value

Re: [R-sig-Geo] over() in sp package

2015-04-14 Thread Kenny Bell
Thanks so much for all this. Yes, I'm after the area weighted averages. The eventual application is to aggregate a 2.5 arcminute temperature grid up to a zip-5 polygon, many of which overlap only 2-3 grid cells. On Mon, Apr 13, 2015 at 10:47 PM, Edzer Pebesma < edzer.pebe...@uni-muenster.de> wrote

Re: [R-sig-Geo] over() in sp package

2015-04-15 Thread Edzer Pebesma
On 04/14/2015 06:58 PM, Kenny Bell wrote: > Thanks so much for all this. Yes, I'm after the area weighted averages. The > eventual application is to aggregate a 2.5 arcminute temperature grid up to > a zip-5 polygon, many of which overlap only 2-3 grid cells. One approach would be to use spsample

Re: [R-sig-Geo] over() in sp package

2015-04-16 Thread Kenny Bell
Thanks so much for this. The code does work. However, the gIntersection() stage is very time intensive, so I will continue to use my own code that relies on joinPolys in PBSmapping (faster). It also allows you to store the rows/weights of the grid so that aggregating many grids to polygons is fea