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

Els Ducheyne educheyne at avia-gis.be
Fri Mar 30 13:58:35 CEST 2012


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



More information about the R-sig-Geo mailing list