Skip to content
Prev 9273 / 29559 Next

center of mass for variable values in a grid

On Sat, Sep 11, 2010 at 12:49 AM, Waichler, Scott R
<Scott.Waichler at pnl.gov> wrote:
If your data is in a data frame of coordinates x, y, (and maybe z),
and variable W for all cells, and all your cells are the same size,
then its just the weighted average of the coordinate (assuming your
dataframe is the complete grid). So:

 xm = sum(d$x*d$W)/sum(d$W)
 ym = sum(d$y*d$W)/sum(d$W)

Or have I missed something?

Barry