Calculate Closest Point from 2 Large Datasets with Coordinates (Lat / Lon)

ialvaran

New Member
Joined
Dec 29, 2011
Messages
9
I would like to calculate the closest distance between two large datasets (tables). Table 1 and Table 2 have location IDs and coordinates (LAT / LON). I would like to know which data point in Table 2 is closest to the data points in Table 1. The calculation should also include the closest (or shortest) distance in meters or feet.

Please find below sample tables (1 and 2) including a sample desired output.

Table 1
Location_ID_Table1LATITUDE_Table1LONGITUDE_Table1
Table1_000000132.7875116-96.8042723
Table1_000000232.9506823-97.0399645
Table1_000000332.9979846-96.7823867
Table1_000000432.8288923-97.4046827
Table1_000000532.8047396-96.6839268
Table1_000000632.804776-96.6839919
Table1_000000732.8048567-96.6839509
Table1_000000832.9463226-96.7004484
Table1_000000932.9554295-96.7115144
Table1_000001033.1568095-96.844646

<tbody>
</tbody>

Table 2
Location_ID_Table2LATITUDE_Table2LONGITUDE_Table2
Table2_000000132.7716152-97.1064349
Table2_000000232.6356708-96.9003413
Table2_000000332.6356984-96.9002808
Table2_000000432.6357211-96.9002707
Table2_000000532.6357226-96.9003323
Table2_000000632.6357466-96.9003532
Table2_000000732.6357724-96.9002676
Table2_000000832.6357726-96.9004123
Table2_000000932.6357788-96.9002719
Table2_000001032.6076538-97.0925508

<tbody>
</tbody>

Desired Output
Location_ID_Table1LATITUDE_Table1LONGITUDE_Table1Distance from closest point from Table 2Closest Location_ID_Table2
Table1_000000132.7875116-96.80427230.01Table2_0000014
Table1_000000232.9506823-97.03996451.00Table2_0000034
Table1_000000332.9979846-96.78238672.15Table2_0000678
Table1_000000432.8288923-97.40468270.15Table2_0000659
Table1_000000532.8047396-96.68392685.00Table2_0000012
Table1_000000632.804776-96.68399190.35Table2_0000032
Table1_000000732.8048567-96.683950910.56Table2_0000958
Table1_000000832.9463226-96.70044843.25Table2_0000026
Table1_000000932.9554295-96.71151441.65Table2_0001032
Table1_000001033.1568095-96.8446460.89Table2_0000020

<tbody>
</tbody>


Thank you in advance for the help.

Jon
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Last edited:
Upvote 0
Mr. Steele,

Thank you for the quick reply. I have been site searching Mr. Excel via Google and was not able to find a viable solution.

Your second link that you provided below (https://www.mrexcel.com/forum/excel-...st-office.html) helped. That is exactly what I am looking for. Good thing you also provided the distance between points in one of your replies. :)

I appreciate your help to the community.

Thanks again.

Jon



I believe what you need to do is create a formula that calculates all of the distances between all of the points. Review these threads and let us know whether or not they help.

https://www.mrexcel.com/forum/excel-questions/966498-create-territories.html

https://www.mrexcel.com/forum/excel...ongitude-coordinates-find-closest-office.html

credit is due here: BlueMM: Excel formula to calculate distance between 2 latitude, longitude (lat/lon) points (GPS positions)
 
Upvote 0
You're welcome. I'm glad it helped.

Calculating the Great Circle Distance using those trig formulas allows us to create a grid of distances. Finding the shortest trips between them all is then a simple matter of INDEX and MATCH, I think.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top