[R-sig-Geo] Resampling rasters with count data
edzer.pebesma at uni-muenster.de
Tue Jun 21 19:32:36 CEST 2011
Simon, package sp has an aggregate method:
grd1 = SpatialPixels(SpatialPoints(expand.grid(1:100,1:100)))
grd2 = SpatialPixels(SpatialPoints(expand.grid(0:100 * 1.5,0:100 * 1.5)))
grd1df = SpatialPixelsDataFrame(grd1, data.frame(counts=rpois(10000,10)))
res = aggregate(grd1df, grd2, function(x) ifelse(nrow(x)>0,sum(x),0))
# check count integrety:
read more in the vignette on overlay and aggregation:
Please note the pattern in the output grid: grid cell counts in grd1df
are not redistributed over new grid cells they overlap with, they are
essentially considered as points, and assigned to the new grid cell in
which their center falls.
No doubt package raster can do the same thing.
On 06/21/2011 06:21 PM, O'Hanlon, Simon J wrote:
> Dear list,
> does anybody know of a method to resample rasters which contain count data? The 'normal' way of resampling would be to perform some interpolation between cells to smooth between the values, for instance if you have a raster of 1km by 1km cells and you resample to 5by 5km cells you would typically employ bilinear or cubic resampling methods to average out the values at the higher resolution.
> However, as I have population count data I want to maintain the integrity of the count. I have a raster of square cells which is 523 by 307 cells, which I need to resample to slightly larger cells which will give me 477 columns by 275 rows, ensuring that the total count across the slightly larger cells adds up to that of the original dataset.
> Many thanks for your thoughts.
> Simon O'Hanlon,
> Department of Infectious Disease Epidemiology
> Imperial College London
> [[alternative HTML version deleted]]
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
More information about the R-sig-Geo