Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Fuzzy matching (so to say) based on geographical coordinates

From   Nils Braakmann <>
Subject   st: Fuzzy matching (so to say) based on geographical coordinates
Date   Mon, 13 Jun 2011 14:52:33 +0100

Hi everyone,

I have the following problem I would appreciate some help with: I have
two data files, one containing the location of certain events, the
other containing centroids of regions. Locations in both cases are
defined by latitude and longitude (lat and lon). What I aim to do is
to match each event to the nearest region, where the definition of
"nearest" is based on the ellipsoidal distance between the two
coordinates. The distances themselves could be computed using
-geodist-by Robert Picard.

The coordinates in both data sets look like:
    |      lat         lon |
  1. | 55.22918   -161.9152 |
  2. | 52.24265   -175.1298 |
  3. | 61.17837   -149.1864 |
  4. | 60.93916   -160.1473 |
  5. | 58.74463   -156.9881 |

I presume one way to proceed would be to compute all pairwise
distances between every event and every region and keep the respective
minimum. However, as I would expect problems such as mine to appear
rather frequently in fields such as geography, I wonder whether anyone
knows of a simpler way or of a program/ado-file (might be outside of
Stata) that could do the job. I basically try to avoid reinventing the
wheel for something that might be a fairly standard problem.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index