# Calculate distance between multiple locations

**URL:** <https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337>\
**Category:** Ask for Help\
**Created:** [June 23, 2024, 11:00pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337 "2024-06-23T23:00:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [June 23, 2024, 11:00pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/1 "2024-06-23T23:00:51Z")

</div>

I have a project list table that contains a coordinate column (lat/lng), so I want to find projects that are less than 100 meters apart.  
Thank you for helping

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 23, 2024, 11:36pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/2 "2024-06-23T23:36:03Z")

</div>

So you mean you need some sort of a matrix of distance between each pair of location to see which pairs are less than 100 meters apart?

---

<div class="post-metadata">

**Author:** ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)\
**Post date:** [June 24, 2024, 9:25am UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/3 "2024-06-24T09:25:25Z")

</div>

I was intrigued and went over to ChatGPT. Not sure if this helps:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/2/720b18252bd6b2cccb38020fd6d5da9282ad3cc6.png)

distance = 2 \* 6371 \* ASIN(SQRT(POWER(SIN((lat2 - lat1) \* PI() / 180 / 2), 2) + COS(lat1 \* PI() / 180) \* COS(lat2 \* PI() / 180) \* POWER(SIN((lon2 - lon1) \* PI() / 180 / 2), 2)))

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [June 24, 2024, 11:52am UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/4 "2024-06-24T11:52:03Z")

</div>

There’s already a column type to calculate distance. I think the question is more about calculating distance from what to what?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [June 25, 2024, 3:08am UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/5 "2024-06-25T03:08:16Z")

</div>

I think the question is about all the sporadic points and determining which points have a distance between them of less than 100 meters. This would be easier if visualized with radius circles around all the points on the map. This requires advanced calculations.

---

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [June 25, 2024, 9:54am UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/6 "2024-06-25T09:54:49Z")

</div>

yes exactly  
but maybe more than 2 match

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [June 25, 2024, 12:44pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/7 "2024-06-25T12:44:19Z")

</div>

How would you view this in the app? Would you open a project first and then want to see a list of other projects within 100 meters of the project you are viewing?

---

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [June 25, 2024, 8:53pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/8 "2024-06-25T20:53:57Z")

</div>

We have a table that contains many project(rows) and thay have X,Y cordinate.  
I want to compare those by distance and if thay had less than 100 meters distance together then show those

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 25, 2024, 11:42pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/9 "2024-06-25T23:42:36Z")

</div>

So it has to be shown pair-wise in a list, and not like what Jeff described here?

> [@Jeff\_Hager](#):
>
> Would you open a project first and then want to see a list of other projects within 100 meters of the project you are viewing?

---

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [June 26, 2024, 9:21pm UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/10 "2024-06-26T21:21:17Z")

</div>

Well, we can do this too.  
Also, can we make the user input the variable distance(e.g.100,50,…)?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 27, 2024, 12:46am UTC](https://community.glideapps.com/t/calculate-distance-between-multiple-locations/74337/11 "2024-06-27T00:46:30Z")

</div>

I think you can do it like Jeff said:

- On entry to the project, set the address of the project to a column in your user profiles.

- Use a distance column to calculate the distance from each of your projects to the address above. I think you want to return kilometers here. Add a math column to convert it to meters by multiplying 1000.

- Add another column to store the variable distance in the user profiles table, add a number entry column for the user to write to that, make sure they know they’re writing in meters.

- Add a filter in your projects collection to filter the meter distance to be less than or equal to the user’s input.
