[R-sig-Geo] Does over() in sp work with "fun=sum"?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Dec 20 16:09:57 CET 2016


Hi Phuong, according to the documentation, the aggregation function
argument of over is named 'fn', not 'fun'.

Note that if you have count data, sp::over may not correctly
redistribute them the way you'd like, i.e. such that the total remains
the same. I'm working on an area-weighted interpolation in [1] that
deals both with extensive (count) and intensive (e.g. population
density) variables. This is still on github.

Best regards,

[1] https://github.com/edzer/sfr/blob/master/R/geom.R#L468-L488

On 20/12/16 15:05, Truong Ngoc Phuong wrote:
> Dear list,
> I try to simply aggregate some gridded data, but it seems like there is no
> difference between "fun=mean" or "fun=sum". Did i do some thing wrong?
> 
>> pop.v = over(gridv, pop_u, fun=sum)$band1
>> summary(pop.v)
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>   74.00   89.00   97.00   92.89  100.00  105.00
>> pop.v = over(gridv, pop_u, fun=mean)$band1
>> summary(pop.v)
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>   74.00   89.00   97.00   92.89  100.00  105.00
> 
> Thanks,
> Phuong
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics  (ifgi),  University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20161220/8c8323a4/attachment.bin>


More information about the R-sig-Geo mailing list