Geo::MedianCenter::XS - Find the median center of locations on earth
use Geo::MedianCenter::XS qw/haversine_distance_dec median_center/; my $distance = haversine_distance_dec( 54.728569, 8.7057573, # Dagebuell-Hafen 54.730320, 8.7289753, # Dagebuell-Kirche ); my ($center_lat, $center_lon) = median_center({ points => [ [ 54.728569, 8.7057573 ], # Dagebuell-Hafen [ 54.730320, 8.7289753 ], # Dagebuell-Kirche [ 54.639998, 8.6017305 ], # Langeness [ 54.492014, 8.8648961 ], # Nordstrand ], });
This module finds the geometric median point of locations on the earth's surface. Also known as euclidean space this is the point where the sum of great circle distances to the locations is minimal. The point is more resistant to outliers than the mean center. The module will guess a point and refine it based on the (weighted) mean center until a good enough approximation is found.
Computes the median center of a list of points. Options are points, an array of arrays of latitude and longitude in decimal degrees and optionally a weight; tolerance, a number in meters, if the iterative algorithm improves its approximation by at most this value, the function will return; max_iterations, the function will return after this many attempts to refine the approximation. Returns the latitude and longitude in decimal degrees.
points
tolerance
max_iterations
Computes the distance between the two points using the Haversine formula in meters. Latitude and longitude are specified in decimal degrees.
Computes the distance between the two points using the Haversine formula in meters. Latitude and longitude are specified in radians.
The function median_center is exported by default, the other functions on request.
median_center
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geo-MedianCenter-XS
Copyright (c) 2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>. This module is licensed under the same terms as Perl itself.
To install Geo::MedianCenter::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::MedianCenter::XS
CPAN shell
perl -MCPAN -e shell install Geo::MedianCenter::XS
For more information on module installation, please visit the detailed CPAN module installation guide.