GEODIST
GEODIST key member1 member2 [M | KM | FT | MI]
- Group
- Geospatial
- Complexity
- O(1)
- Arity
- -4 (at least 4 words, counting the command name)
- Flags
- read-only
- Keys
- first 1, last 1, step 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
Section titled “Options”| Unit | Meaning |
|---|---|
M |
Meters (the default). |
KM |
Kilometers. |
FT |
Feet. |
MI |
Miles. |
Units are case-insensitive.
Return value
Section titled “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
Section titled “Examples”127.0.0.1:6379> GEOADD cities -0.1276 51.5072 london 2.3522 48.8566 paris(integer) 2127.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
Section titled “Compatibility”Same as Redis 7 and Valkey 8, including the Earth radius used, so distances match.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.