# GEODIST

```json metadata
{
  "schema_version": 2,
  "title": "GEODIST",
  "description": "Returns the distance between two members of a geospatial index.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "arguments": [{"display_text":"key","key_spec_index":0,"name":"key","type":"key"},{"display_text":"member1","name":"member1","type":"string"},{"display_text":"member2","name":"member2","type":"string"},{"arguments":[{"display_text":"m","name":"m","token":"M","type":"pure-token"},{"display_text":"km","name":"km","token":"KM","type":"pure-token"},{"display_text":"ft","name":"ft","token":"FT","type":"pure-token"},{"display_text":"mi","name":"mi","token":"MI","type":"pure-token"}],"name":"unit","optional":true,"type":"oneof"}],
  "syntax_fmt": "GEODIST key member1 member2 [M | KM | FT | MI]",
  "complexity": "O(1)",
  "group": "geo",
  "command_flags": ["readonly"],
  "acl_categories": ["@read","@geo","@slow"],
  "since": "3.2.0",
  "arity": -4,
  "key_specs": [{"RO":true,"access":true,"begin_search":{"spec":{"index":1},"type":"index"},"find_keys":{"spec":{"keystep":1,"lastkey":0,"limit":0},"type":"range"}}],
  "tableOfContents": {"sections":[{"id":"required-arguments","title":"Required arguments"},{"id":"optional-arguments","title":"Optional arguments"},{"id":"examples","title":"Examples"},{"id":"redis-software-and-redis-cloud-compatibility","title":"Redis Software and Redis Cloud compatibility"},{"id":"return-information","title":"Return information"}]}

,
  "codeExamples": []
}
```

Return the distance between two members in the geospatial index represented by the sorted set.

Given a sorted set representing a geospatial index, populated using the [`GEOADD`](https://redis.io/docs/latest/commands/geoadd) command, the command returns the distance between the two specified members in the specified unit.

If one or both the members are missing, the command returns NULL.

The unit must be one of the following, and defaults to meters:

* **m** for meters.
* **km** for kilometers.
* **mi** for miles.
* **ft** for feet.

The distance is computed assuming that the Earth is a perfect sphere, so errors up to 0.5% are possible in edge cases.

## Required arguments

<details open><summary><code>key</code></summary>

The name of the key that holds the geospatial index (a sorted set).

</details>

<details open><summary><code>member1</code></summary>

The first member.

</details>

<details open><summary><code>member2</code></summary>

The second member.

</details>

## Optional arguments

<details open><summary><code>M | KM | FT | MI</code></summary>

The unit for the returned distance: meters (`M`, the default), kilometers (`KM`), feet (`FT`), or miles (`MI`).

</details>

## Examples


redis> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 2
redis> GEODIST Sicily Palermo Catania
"166274.1516"
redis> GEODIST Sicily Palermo Catania km
"166.2742"
redis> GEODIST Sicily Palermo Catania mi
"103.3182"
redis> GEODIST Sicily Foo Bar
(nil)


## Redis Software and Redis Cloud compatibility

| Redis<br />Software | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
|:----------------------|:-----------------|:------|
| <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> |  |

## Return information

**RESP2:**

One of the following:
* [Nil reply](../../develop/reference/protocol-spec#bulk-strings): one or both of the elements are missing.
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): distance as a double (represented as a string) in the specified units.

**RESP3:**

One of the following:
* [Null reply](../../develop/reference/protocol-spec#nulls): one or both of the elements are missing.
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): distance as a double (represented as a string) in the specified units.



