Geospatial

The Redis geospatial data type allows us to store location data in the form of coordinates. Once stored, we can use geospatial indexes to query this data in different ways. For example, it can be used to find the distance between two locations or places within a certain radius.

Geospatial commands

To better understand how geospatial indexes work in Redis, let’s explore some of the commands associated with this data type.

The GeoAdd command

The GeoAdd command is used to add data to a geospatial index. In the following example, we add the member city1 with a latitude and longitude (coordinates) of 40 and -83, respectively, to an index named cities:

Get hands-on with 1200+ tech skills courses.