Bookmark and Share

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


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

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


From   Rüdiger Vollmeier <[email protected]>
To   [email protected]
Subject   st: Matching procedure based on shortest distance given latitudes and longitudes
Date   Thu, 9 Feb 2012 11:34:41 +0100

Hello guys,

I want to match observations in each observation in a given year with
one observation in another year based on the shortest geographical
distance between them given the latitudes and longitudes of each
observation.

I.e. the simplified structure of the dataset looks as follows:

id	year	   longitude	latitude
1 	2006	  19.923		40.794
2 	2006   19.949		40.711
1	2010	  19.940		40.721
2 	2010	  22.001		50.122

Hence, I would like to match each observation in 2006 with the one
observation in 2010 that is closest AND that had not been matched to
any observation in 2006 before.

The previously discussed -nearstat- command (thanks to Wilner!) cannot
be applied directly to this problem as it could match the same
observation in 2010 with multiple observations in 2006 (i.e. in this
example, the year 2010 observation with id 1 is closest to both
observations in 2006 - and hence would be matched).

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?
*
*   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/


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