IDEAS home Printed from

GEONEAR: Stata module to find nearest neighbors using geodetic distances


  • Robert Picard

Programming Language



geonear finds the nearest neighbors using geodetic distances, i.e. the length of the shortest curve between two points along the surface of a mathematical model of the earth. Both great-circle and ellipsoid distances are available. geonear returns a specific count of nearest neighbors and/or all neighbors within a specified distance. geonear uses a divide and conquer strategy to significantly reduce the number of distances that must be computed. The approach involves splitting the initial set of locations into progressively smaller geographic regions while at the same time safely reducing the set of potential neighbors for each region. Generally, geonear will predictably find the nearest neighbors in a linear time even though the size of the overall problem increases exponentially. In other words doubling the size of both location sets simply doubles the number of regions and thus doubles the run time.

Suggested Citation

  • Robert Picard, 2010. "GEONEAR: Stata module to find nearest neighbors using geodetic distances," Statistical Software Components S457146, Boston College Department of Economics, revised 14 Sep 2019.
  • Handle: RePEc:boc:bocode:s457146
    Note: This module should be installed from within Stata by typing "ssc install geonear". The module is made available under terms of the GPL v3 ( Windows users should not attempt to download these files with a web browser.

    Download full text from publisher

    File URL:
    File Function: program code
    Download Restriction: no

    File URL:
    File Function: help file
    Download Restriction: no


    Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.

    Cited by:

    1. Kelly, Andrea & Lindo, Jason M. & Packham, Analisa, 2020. "The power of the IUD: Effects of expanding access to contraception through Title X clinics," Journal of Public Economics, Elsevier, vol. 192(C).
    2. Branson, Nicola & Byker, Tanya, 2018. "Causes and consequences of teen childbearing: Evidence from a reproductive health intervention in South Africa," Journal of Health Economics, Elsevier, vol. 57(C), pages 221-235.
    3. Nirav Mehta, 2017. "Competition In Public School Districts: Charter School Entry, Student Sorting, And School Input Determination," International Economic Review, Department of Economics, University of Pennsylvania and Osaka University Institute of Social and Economic Research Association, vol. 58(4), pages 1089-1116, November.
    4. Myers, Caitlin & Ladd, Daniel, 2020. "Did parental involvement laws grow teeth? The effects of state restrictions on minors’ access to abortion," Journal of Health Economics, Elsevier, vol. 71(C).
    5. Martin Micheli & Jan Rouwendal & Jasper Dekkers, 2019. "Border Effects in House Prices," Real Estate Economics, American Real Estate and Urban Economics Association, vol. 47(3), pages 757-783, September.
    6. Nikolova, Milena & Popova, Olga & Otrachshenko, Vladimir, 2022. "Stalin and the origins of mistrust," Journal of Public Economics, Elsevier, vol. 208(C).
    7. Konte, Maty & Vincent, Rose Camille, 2021. "Mining and quality of public services: The role of local governance and decentralization," World Development, Elsevier, vol. 140(C).
    8. Jason M. Lindo & Caitlin Knowles Myers & Andrea Schlosser & Scott Cunningham, 2020. "How Far Is Too Far? New Evidence on Abortion Clinic Closures, Access, and Abortions," Journal of Human Resources, University of Wisconsin Press, vol. 55(4), pages 1137-1160.
    9. Myers, Caitlin Knowles, 2021. "Cooling off or Burdened? The Effects of Mandatory Waiting Periods on Abortions and Births," IZA Discussion Papers 14434, Institute of Labor Economics (IZA).
    10. Martin Micheli & Jan Rouwendal & Jasper Dekkers, 2014. "Border Eff ects in House Prices," Ruhr Economic Papers 0511, Rheinisch-Westfälisches Institut für Wirtschaftsforschung, Ruhr-Universität Bochum, Universität Dortmund, Universität Duisburg-Essen.
    11. repec:zbw:rwirep:0511 is not listed on IDEAS
    12. Nicola Branson & David Lam, 2017. "The impact of the no-fee school policy on enrolment and school performance: Evidence from NIDS Waves 1-3," SALDRU Working Papers 197, Southern Africa Labour and Development Research Unit, University of Cape Town.
    13. Myers, Caitlin Knowles, 2021. "Measuring the Burden: The Effect of Travel Distance on Abortions and Births," IZA Discussion Papers 14556, Institute of Labor Economics (IZA).


    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:bocode:s457146. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F Baum (email available below). General contact details of provider: .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.