Help with a Countif/Sumif over 2 columns

StuckwithGeo

New Member
Joined
Aug 23, 2016
Messages
1
Hello!

I am hoping someone can help :)

I have tons of data similar to the sample data below. I am trying to figure out how many other lat, longs within the whole list are within 5km of each lat and long. For example, for the lat/long in B2, C2, how many other lat/longs in the whole list are within 5km. I then want to do the same with B3, C3 and B4, C4 etc.
etc.

The formula for the distance between lat/long is: =ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))) *6371

ABCD
1LongLatHow many other Long, Lats within 5km?
2
0.125884

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
0.115445

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
?
3
51.4188

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
0.115445

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
4
51.6298

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
-0.0743092

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
5
51.4718

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>
-0.0743092

<colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>

<tbody>
</tbody>


Thank you!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
This should work. You just need to expand the ranges between each latitude and the others (and do the same for longitude), then count how many of those differences are less than or equal to the hurdle (5 in your case) and subtract 1 (because the formula compares each latitude to itself, thereby reporting an extra TRUE).

Are you sure you haven't mixed up the latitudes with the longitudes? Most of those coordinates are in the middle of pirate waters off eastern Africa.

references:
http://www.mrexcel.com/forum/excel-...ongitude-coordinates-find-closest-office.html
http://en.wikipedia.org/wiki/Great-circle_distance
BlueMM: Excel formula to calculate distance between 2 latitude, longitude (lat/lon) points (GPS positions)
Latitude And Longitude

ABCD
1PlaceLongLat5
2a0.1258840.1154450
3b51.4188000.1154450
4c51.629800-0.0743090
5d51.471800-0.0743090
6e51.0000000.0000001
7f51.0000000.0100001

<tbody>
</tbody>
Sheet42

Worksheet Formulas
CellFormula
D2=SUMPRODUCT(--((ACOS(COS(RADIANS(90-$C$2:$C$7))*COS(RADIANS(90-C2))+SIN(RADIANS(90-$C$2:$C$7))*SIN(RADIANS(90-C2))*COS(RADIANS($B$2:$B$7-B2)))*6371)<$D$1))-1

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,216,512
Messages
6,131,091
Members
449,618
Latest member
lewismillar

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