[R-sig-Geo] Spatial Join - over and weighted mean

Edzer Pebesma edzer.pebesma at uni-muenster.de
Fri Mar 30 14:17:00 CEST 2012


Els, what being weighted by what exactly? Any chance you can illustrate
your problem by something we can reproduce?

On 03/30/2012 01:58 PM, Els Ducheyne wrote:
> Dear R-SIG-GEO list
> 
> I want to aggregate the mean value of points in a polygon using the over function. 
> #Read the shapefile with the measurements
> shapefilename <- paste(shapefiledir,shortNameIndicator,"_",production.date,sep="")
> point.shapefile <- readShapePoints(paste(shapefilename,".shp",sep=""))
> names(slot(point.shapefile,'data')) <- c("ID",shortNameIndicator)
> 
> 
> #aggregate per polygon by mean and save as shapefile
> aggregate.data<-over(studyzone,point.shapefile,fn=mean)
> row.names(aggregate.data) <- row.names(aggregate.data)
> outPolDF <- SpatialPolygonsDataFrame(studyzone,aggregate.data,match.ID=T)
> writePolyShape(outPolDF,paste(shapefiledir,shortNameIndicator,"_poly_",production.date,".shp",sep=""))
> 
> 
> While this works using the mean function I am unsure how to proceed for a weighted mean - does anyone have a suggestion?
> 
> Many thanks
> Els
> 
> _______________________________________________
> 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
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 mailing list