# How to use location in org-roam?

**URL:** <https://org-roam.discourse.group/t/how-to-use-location-in-org-roam/3159>\
**Category:** Requests\
**Created:** [July 24, 2023, 12:28am UTC](https://org-roam.discourse.group/t/how-to-use-location-in-org-roam/3159 "2023-07-24T00:28:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcoladon](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/gcoladon/32/976_2.png) [@gcoladon](https://org-roam.discourse.group/u/gcoladon)\
**Post date:** [July 24, 2023, 12:28am UTC](https://org-roam.discourse.group/t/how-to-use-location-in-org-roam/3159/1 "2023-07-24T00:28:32Z")

</div>

I would like to be able to put, say, the latitude and longitude for a place into a node for that place, and then be able to find org-roam nodes that are within a specified distance from the first place.

For example, I make nodes for cities that have a person or company or institution I’m interested in. Take for argument’s sake, these nodes I really have:

```auto
:PROPERTIES:
:ID: 210914_155426
:END:
#+title: Palo Alto, CA

```

and

```auto
:PROPERTIES:
:ID: 210914_160652
:END:
#+title: Mountain View, CA

```

What if I added a LATLONG property like this: (I got the lat long from Wikipedia)

```auto
:PROPERTIES:
:ID: 210914_150202
:LATLONG: 37°22′16″N 122°2′15″W
:END:
#+title: Sunnyvale, CA

```

If I had the Mountain View node open in Emacs, I would like to be able to issue a command that would return all the nodes that are within say 10 miles of the lat long (I could put) in the Mountain View node.

I searched the discourse for proximity and location and didn’t find any conversation relevant to this.

---

<div class="post-metadata">

**Author:** ![digitalnotions](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/digitalnotions/32/1352_2.png) [@digitalnotions](https://org-roam.discourse.group/u/digitalnotions)\
**Post date:** [July 26, 2023, 5:29pm UTC](https://org-roam.discourse.group/t/how-to-use-location-in-org-roam/3159/2 "2023-07-26T17:29:32Z")

</div>

I’m interested in this concept as well – very interesting use case.

From my understanding, this should be possible programmatically. [This page](https://www.geeksforgeeks.org/program-distance-two-points-earth/#) has a good example as well as some code in different languages (no Lisp though).

I’d try to write something up in Lisp, but my primary coding language is C, so I’m probably not the best person to provide that.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [July 30, 2023, 5:41pm UTC](https://org-roam.discourse.group/t/how-to-use-location-in-org-roam/3159/3 "2023-07-30T17:41:21Z")

</div>

I have done a [quick experiment (code in Gist)](https://gist.github.com/nobiot/bcccc1033d74b16eefc19e936a4fdba1). It works on my end.

If someone can make it better, I’d love to see improvement. I just took it on as a technical exercise.

To use it:

1. Evaluate all the functions in the Gist
2. Create a couple of test nodes with a `:geo:` property
3. Visit a Org-roam node that has a `:geo:` property – where you are will be the origin
4. Run command `my/list-node-IDs-within-range-of-distance`
5. Enter a number: that is the max distance in kilometers
6. You will see a list of nodes ID that are within the kilometer distance

Please try not to be confused with the fact that the prompt asks for the max distance in kilometers and the resultant pop-up buffer shows the distance in meters. I could not show kilometers without rounding the values to 4km and 44km respectively (4 km vs 4.75 km is large enough for me to care).

 ![image](https://global.discourse-cdn.com/free1/uploads/orgroam/original/2X/5/507f6c10315bf7a4240202957b606bfd15b215fd.jpeg)

Two notes:

- I used `GEO` property name, not `LATLONG` but they denote the same thing
- The value of `GEO` property must be [decimal degrees](https://en.wikipedia.org/wiki/Decimal_degrees) and must be separated by a space
- If you want to use this notation `37°22′16″N 122°2′15″W`, you’d need to convert it
- The algorithm is from [this website](https://www.movable-type.co.uk/scripts/latlong.html) – see the source code for a bit more detail

My test files are as follows.

File 1 (the origin)

```plaintext
:properties:
:modified: 2023-07-30T182055
:ID: 2023-07-30T163232
:geo: 37.3927 -122.042
:end:
#+title: test GEO Mountain View
#+filetags: test

```

File 2

```plaintext
:properties:
:modified: 2023-07-30T164943
:ID: 2023-07-30T164720
:geo: 37.3587 -122.075
:end:
#+title: test GEO 10km Ortega park
#+filetags:

```

File 3

```plaintext
:properties:
:modified: 2023-07-30T165100
:ID: 2023-07-30T165039
:geo: 37.0154 -122.211
:end:
#+title: test GEO more than 10km Devon Port
#+filetags: test

```
