+ Reply to Thread
Results 1 to 4 of 4

GeoCoding - Find the closest point

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    Florida, United States
    MS-Off Ver
    Excel 2007
    Posts
    18

    GeoCoding - Find the closest point

    Hello All,

    As the title states, I have 2 lists with several points, list 1 has ~200k coordinates (Lat/Long), and list 2 has about 2,400 coordinates. The idea is to step through each of the 200k coordinates and find which of the 2,400 coordinates is closest.

    Currently I've been trying it in a spreadsheet, but since I'm using 32bit it goes kaput on me.

    Any ideas?

    The formula for calculating distance between 2 GPS points is as follows:
    Please Login or Register  to view this content.
    Taken from here: http://www.ehow.com/how_7695232_conv...ates-feet.html

    Attached is a small sample of how I've been doing it the brute force method.
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: GeoCoding - Find the closest point

    I think, well, I'm almost sure, that the results are wrong. Why? because the formula as I read the link provided works on degrees, while excel in trigonometrical functions expects radians.

    Anyway as your workbook would be overloaded with formulas (not strange, because 2.4K x 200K is ca 0.5G of complicated formulas), and I do not think 64bits and large ram would make situation much better.

    The macro below has not been optimized yet (still a lot of potential for improvement, especially in reading and writing to columns B:E) but shall do something reasonable for you.
    so insert a part (say just 100 as a starting run) of your 200K list1 points in columns B:C (starting row 5) and all list 2 points in columns N:O (also starting row 5)
    and try:

    Please Login or Register  to view this content.
    The calculated distance is in miles, but of course you can multiply it by 5280 to obtain result in feet.

    You can use attached file, but please before testing on larger sets of data clear content (formulas !!!) of columns F:L.

    If the time is acceptable (shall be few seconds maximum), then try larger sub-set of list1 (say 10000). The time shall be roughly lineary dependant on list1 length (so 100 times longer then previous run - few, may be 10 minutes).

    If it is so - you can try a full run - shall take some 20 times longer - say 3 hrs. Or do it part by part (safer way tahn potentially 3hrs run which breaks after 2.5 hr ).

    So try and let us know how it worked (hopefully) for you.
    Attached Files Attached Files
    Last edited by Kaper; 01-14-2015 at 08:13 AM.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    09-25-2012
    Location
    Florida, United States
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: GeoCoding - Find the closest point

    Thank you sir, giving it a try now. And great catch on the radians within excel.

  4. #4
    Registered User
    Join Date
    09-25-2012
    Location
    Florida, United States
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: GeoCoding - Find the closest point

    Thank you again, looks like it's working well. For the entire set it took ~2 hours.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Using the Google Geocoding API in Excel
    By russkris in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-12-2014, 01:17 AM
  2. Geofencing Lat / Longs (Finding Closest Point) in Excel
    By mattkunkle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-19-2013, 02:05 PM
  3. [SOLVED] How to find the a value closest to a given value
    By BNCOXUK in forum Excel General
    Replies: 2
    Last Post: 02-15-2013, 06:12 AM
  4. Index/Match to find Starting Point of Average, Ending Point of Average Variable
    By tgentry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-09-2012, 01:04 AM
  5. Reverse Geocoding Excel Help (see attachment)
    By zsemago in forum Excel General
    Replies: 1
    Last Post: 02-28-2012, 03:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1