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

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

 From "Dimitriy V. Masterov" To statalist@hsphsun2.harvard.edu Subject Re: st: Fuzzy matching (so to say) based on geographical coordinates Date Mon, 13 Jun 2011 10:21:43 -0400

```Nils,

I think Robert Picard's -geonear- is what you want to use. You can get
it from ssc.

DVM

On Mon, Jun 13, 2011 at 9:52 AM, Nils Braakmann
> 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.
>
> Cheers,
> Nils
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```