Creates centroid of [x,y] coordinates based on a weights field
wt.centroid(x, p, sp = TRUE)
x | sp SpatialPointsDataFrame class object |
---|---|
p | Weights column in x@data slot |
sp | Output sp SpatailPoints class object (TRUE | FALSE) |
A vector or an sp class SpatialPoints object of the weighted coordinate centroid
The weighted centroid is calculated as: [Xw]=[X]*[p], [Yw]=[Y]*[p], [sXw]=SUM[Xw], [sYw]=SUM[Yw], [sP]=SUM[p] wX=[sXw]/[sP], wY=[sYw]/[sP] where; X=X COORDINATE(S), Y=Y COORDINATE(S), p=WEIGHT
Depends: sp
require(sp) data(meuse) coordinates(meuse) = ~x+y wt.copper <- wt.centroid(meuse, 'copper', sp=TRUE) wt.zinc <- wt.centroid(meuse, 'zinc', sp=TRUE) plot(meuse, pch=20, cex=0.75, main='Weighted centroid(s)')