Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: Matching procedure based on shortest distance given latitudes and longitudes

 From brendan.halpin@ul.ie (Brendan Halpin) To statalist@hsphsun2.harvard.edu Subject Re: st: Matching procedure based on shortest distance given latitudes and longitudes Date Thu, 09 Feb 2012 11:58:35 +0000

```On Thu, Feb 09 2012, Rüdiger Vollmeier wrote:

> Does anybody have an idea for a nice solution or is there even a
> command out there that would match based on distance given the
> latitudes and longitudes?

Given a pairwise distance, I'd look at the strategy used by -psmatch2-
to match a case to the case with the closest propensity score. It seems
that the problem is the same. I'm not sure how easy it would be to
extract the relevant functionality, though (it seems to lie mostly in
the match_pscore mata function).

Here's a crude but simple formula to map lat/lon to kilometres:

dist = 111.6234927323819 * sqrt((lat1 - lat2)^2
+ (cos(0.5 * pi * (lat1 + lat2)/180.0) * (lon1 - lon2))^2)

(a fair approximation if lat1 and lat2 are not too different).

Brendan
--
Brendan Halpin,   Department of Sociology,   University of Limerick,   Ireland
Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x 3147