# GEODIST

> Return the distance between two members of a geospatial index.

URL: https://docs.hotkv.com/commands/geodist/

```
GEODIST key member1 member2 [M | KM | FT | MI]
```

- Group: Geospatial
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`GEODIST` returns the distance between two members of the geospatial index at
`key`, measured along the Earth's surface (the Earth is treated as a sphere,
so expect an error of up to about 0.5%).

## Options

| Unit | Meaning |
| --- | --- |
| `M` | Meters (the default). |
| `KM` | Kilometers. |
| `FT` | Feet. |
| `MI` | Miles. |

Units are case-insensitive.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Both members exist | Bulk string: the distance with 4 decimals | Bulk string |
| A member or the key is missing | Nil bulk string | Null |

Error replies: `ERR unsupported unit provided. please use M, KM, FT, MI`, and
`WRONGTYPE` if the key is not a sorted set.

## Examples

```
127.0.0.1:6379> GEOADD cities -0.1276 51.5072 london 2.3522 48.8566 paris
(integer) 2
127.0.0.1:6379> GEODIST cities london paris
"343626.8434"
127.0.0.1:6379> GEODIST cities london paris km
"343.6268"
127.0.0.1:6379> GEODIST cities london atlantis
(nil)
```

## Compatibility

Same as Redis 7 and Valkey 8, including the Earth radius used, so distances
match.

## See also

[GEOADD](https://docs.hotkv.com/commands/geoadd/index.md), [GEOPOS](https://docs.hotkv.com/commands/geopos/index.md), [GEOSEARCH](https://docs.hotkv.com/commands/geosearch/index.md)