Björn Höhrmann

# NAME

Geo::MedianCenter::XS - Find the median center of locations on earth

# SYNOPSIS

``````  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
],
});``````

# DESCRIPTION

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.

## FUNCTIONS

median_center(\%options)

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.

haversine_distance_dec(\$lat1, \$lon1, \$lat2, \$long2)

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.

## EXPORT

The function `median_center` is exported by default, the other functions on request.

# BUG REPORTS

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geo-MedianCenter-XS

``````  Copyright (c) 2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>.