Readers of Kottke.org will remember a discussion a week back about where in the world the highest concentration of Starbucks coffee shops might be. One blogger was inspired to calculate the exact center of gravity of all Starbucks in New York, and mapped it. It was a hard slog, and it got him some press.
That was then. this is now.
Blogger “Brammeleman” writes in Dutch (so I’ll translate loosely) that his family is discussing where to have the next family reunion. It must be a nerdy family, as everyone immediately agreed it should be at the family’s center of gravity. The only question remaining is, what determines the weighting of each individual family member?
While the rest of the family argues it out (age? generation? marital status?), our blogger has gone off and produced a center of gravity calculator for Google Earth. In the true political tradition of the Dutch, the calculator assigns everyone an equal weighting.
Here’s how it works: In Google Earth, make a new folder (Command-Shift N). Then, make a new placemark at the location of each family member and add it to the folder. Finally, save the folder to your desktop as a KML file. Now import it into our pseudonymous blogger’s web app, and you instantly get a KML file back with a placemark added at the center of gravity.
(I tried it. My immediate family is all over the place — London, Switzerland and me here in Stockholm, yet the center of gravity for us is in tiny Belgium, near Li√Æge. As we’re Belgian, that’s rather spooky.)
The script makes one major simplifying assumption — that the Earth is flat. The PHP script won’t get tripped up by the dateline, but be sure not to live too spread out, or around a pole.
[Geeky postscript: That’s a fun programming question: “Given a set of arbitrary points on the surface of a sphere referenced by latitude and longitude, write a program to determine the point on the sphere closest to the three-dimensional center of gravity of the points, in terms of latitude and longitude.” Brammeleman’s script is practically there. Just his final latitude calculation is off for most sets of widely spread points. Instead of:
$lat = rad2deg(asin($meanz));
it needs to read:
$meanx = $sumx / $placemark_count;
$meany = $sumy / $placemark_count;
$lat = rad2deg(atan($meanz/(sqrt($meanx^2+$meany^2))));
…I believe, hoping for no divisions by zero. But I’m often wrong:-)]