Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matching pairs of closest locations

    Hello,

    I have two CSV files; call them A and B. Each file has a list of names of areas linked to the areas' central coordinates (longitude and latitude). I would like to link each area in file A to the closest area in file B. In addition, I hope to generate a variable that shows the distance between the matched areas' coordinates. How can I achieve this?

    Thank you very much.

  • #2
    Code:
    ssc install geodist, replace
    help geodist
    You want to first match each observation in A to all observations in B, calculate the distances using geodist, sort and keep the closest distance. If the files are not big, see

    Code:
    help cross
    on forming pairwise combinations. If the files are too large, merge each observation at a time, e.g., using a loop.

    Comment

    Working...
    X