Back to results for “Commands”
Redis › Geospatial Data in Redis

How do you find the distance between two stored locations in Redis?

Beginner

Answer

You use the GEODIST command, specifying the two member names whose distance you want to calculate along with an optional unit like meters, kilometers, or miles, and Redis returns the calculated distance between those two points based on their stored geographic coordinates.
GEODIST locations 'San Francisco' 'New York' km
Real-world example A travel planning application calculates the distance between two cities a user has selected, using GEODIST to instantly return the distance in kilometers without needing a separate geographic calculation service.

Common follow-ups: What units does GEODIST support besides kilometers?;How accurate is the distance calculation compared to a dedicated mapping service?