{
  "schema_version": 2,
  "id": "develop/data-types/geospatial",
  "title": "Redis geospatial",
  "url": "https://redis.io/docs/latest/develop/data-types/geospatial/",
  "summary": "Introduction to the Redis Geospatial data type",
  "aliases": [
    "/data-types/geospatial/",
    "/manual/data-types/geospatial/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-10T15:45:53+01:00",
  "page_type": "content",
  "content_hash": "2aa960bd910fe3b7dc4553b789ab8ed5f54156a929c2b7973090e910841b5607",
  "sections": [
    {
      "id": "geospatial-command-summary",
      "title": "Geospatial command summary",
      "role": "content",
      "text": "**10 commands in this group:**\n\n[View all geo commands](https://redis.io/commands/?group=geo)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [GEOADD](https://redis.io/commands/geoadd/) | Adds one or more members to a geospatial index. The key is created if it doesn't exist. | O(log(N)) for each item added, where N is the n... | 3.2.0 |\n| [GEODIST](https://redis.io/commands/geodist/) | Returns the distance between two members of a geospatial index. | O(1) | 3.2.0 |\n| [GEOHASH](https://redis.io/commands/geohash/) | Returns members from a geospatial index as geohash strings. | O(1) for each member requested. | 3.2.0 |\n| [GEOPOS](https://redis.io/commands/geopos/) | Returns the longitude and latitude of members from a geospatial index. | O(1) for each member requested. | 3.2.0 |\n| [GEORADIUS](https://redis.io/commands/georadius/) | Queries a geospatial index for members within a distance from a coordinate, optionally stores the result. | O(N+log(M)) where N is the number of elements i... | 3.2.0 |\n| [GEORADIUS_RO](https://redis.io/commands/georadius_ro/) | Returns members from a geospatial index that are within a distance from a coordinate. | O(N+log(M)) where N is the number of elements i... | 3.2.10 |\n| [GEORADIUSBYMEMBER](https://redis.io/commands/georadiusbymember/) | Queries a geospatial index for members within a distance from a member, optionally stores the result. | O(N+log(M)) where N is the number of elements i... | 3.2.0 |\n| [GEORADIUSBYMEMBER_RO](https://redis.io/commands/georadiusbymember_ro/) | Returns members from a geospatial index that are within a distance from a member. | O(N+log(M)) where N is the number of elements i... | 3.2.10 |\n| [GEOSEARCH](https://redis.io/commands/geosearch/) | Queries a geospatial index for members inside an area of a box or a circle. | O(N+log(M)) where N is the number of elements i... | 6.2.0 |\n| [GEOSEARCHSTORE](https://redis.io/commands/geosearchstore/) | Queries a geospatial index for members inside an area of a box or a circle, optionally stores the result. | O(N+log(M)) where N is the number of elements i... | 6.2.0 |\n\n\n\nRedis geospatial indexes let you store coordinates and search for them.\nThis data structure is useful for finding nearby points within a given radius or bounding box.\n\n> [!NOTE]\n> Take care not to confuse the Geospatial data type with the\n> [Geospatial](https://redis.io/docs/latest/develop/ai/search-and-query/advanced-concepts/geo)\n> features in [Redis Search](https://redis.io/docs/latest/develop/ai/search-and-query).\n> Although there are some similarities between these two features, the data type is intended\n> for simpler use cases and doesn't have the range of format options and queries\n> available in Redis Search."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Suppose you're building a mobile app that lets you find all of the bike rental stations closest to your current location.\n\nAdd several locations to a geospatial index:\nFoundational: Add geographic coordinates to a geospatial index using GEOADD to store location data\n\n**Commands:** GEOADD\n\n**Complexity:**\n- GEOADD: O(log(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Synchronous - Jedis), JavaScript (Node.js), Python\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nFind all locations within a 5 kilometer radius of a given location, and return the distance to each location:\nProximity search: Use GEOSEARCH to find locations within a radius or bounding box when you need to discover nearby points\n\n**Difficulty:** Intermediate\n\n**Builds upon:** geoadd\n\n**Commands:** GEOSEARCH\n\n**Complexity:**\n- GEOSEARCH: O(N+log(M)\n\n**Available in:** Redis CLI, C#, Go, Java (Synchronous - Jedis), JavaScript (Node.js), Python\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "learn-more",
      "title": "Learn more",
      "role": "related",
      "text": "* [Redis Geospatial Explained](https://www.youtube.com/watch?v=qftiVQraxmI) introduces geospatial indexes by showing you how to build a map of local park attractions.\n* [Redis University's RU101](https://university.redis.com/courses/ru101/) covers Redis geospatial indexes in detail."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> GEOADD bikes:rentable -122.27652 37.805186 station:1\n(integer) 1\n> GEOADD bikes:rentable -122.2674626 37.8062344 station:2\n(integer) 1\n> GEOADD bikes:rentable -122.2469854 37.8104049 station:3\n(integer) 1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "bool res1 = db.GeoAdd(\"bikes:rentable\", -122.27652, 37.805186, \"station:1\");\n        Console.WriteLine(res1);    // >>> True\n\n        bool res2 = db.GeoAdd(\"bikes:rentable\", -122.2674626, 37.8062344, \"station:2\");\n        Console.WriteLine(res2);    // >>> True\n\n        bool res3 = db.GeoAdd(\"bikes:rentable\", -122.2469854, 37.8104049, \"station:3\");\n        Console.WriteLine(res3);    // >>> True",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "go",
      "code": "res1, err := rdb.GeoAdd(ctx, \"bikes:rentable\",\n\t\t&redis.GeoLocation{\n\t\t\tLongitude: -122.27652,\n\t\t\tLatitude:  37.805186,\n\t\t\tName:      \"station:1\",\n\t\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1) // >>> 1\n\n\tres2, err := rdb.GeoAdd(ctx, \"bikes:rentable\",\n\t\t&redis.GeoLocation{\n\t\t\tLongitude: -122.2674626,\n\t\t\tLatitude:  37.8062344,\n\t\t\tName:      \"station:2\",\n\t\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2) // >>> 1\n\n\tres3, err := rdb.GeoAdd(ctx, \"bikes:rentable\",\n\t\t&redis.GeoLocation{\n\t\t\tLongitude: -122.2469854,\n\t\t\tLatitude:  37.8104049,\n\t\t\tName:      \"station:3\",\n\t\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3) // >>> 1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "java",
      "code": "long res1 = jedis.geoadd(\"bikes:rentable\", -122.27652, 37.805186, \"station:1\");\n      System.out.println(res1); // 1\n\n      long res2 = jedis.geoadd(\"bikes:rentable\", -122.2674626, 37.8062344, \"station:2\");\n      System.out.println(res2); // 1\n\n      long res3 = jedis.geoadd(\"bikes:rentable\", -122.2469854, 37.8104049, \"station:3\");\n      System.out.println(res2); // 1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "javascript",
      "code": "const res1 = await client.geoAdd('bikes:rentable', { \n  longitude: -122.27652,\n  latitude: 37.805186,\n  member: 'station:1'\n});\nconsole.log(res1)  // 1\n\nconst res2 = await client.geoAdd('bikes:rentable', {\n  longitude: -122.2674626,\n  latitude: 37.8062344,\n  member: 'station:2'\n});\nconsole.log(res2)  // 1\n\nconst res3 = await client.geoAdd('bikes:rentable', {\n  longitude: -122.2469854,\n  latitude: 37.8104049,\n  member: 'station:3'\n})\nconsole.log(res3)  // 1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "python",
      "code": "res1 = r.geoadd(\"bikes:rentable\", [-122.27652, 37.805186, \"station:1\"])\nprint(res1)  # >>> 1\n\nres2 = r.geoadd(\"bikes:rentable\", [-122.2674626, 37.8062344, \"station:2\"])\nprint(res2)  # >>> 1\n\nres3 = r.geoadd(\"bikes:rentable\", [-122.2469854, 37.8104049, \"station:3\"])\nprint(res3)  # >>> 1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "plaintext",
      "code": "> GEOSEARCH bikes:rentable FROMLONLAT -122.2612767 37.7936847 BYRADIUS 5 km WITHDIST\n1) 1) \"station:1\"\n   2) \"1.8523\"\n2) 1) \"station:2\"\n   2) \"1.4979\"\n3) 1) \"station:3\"\n   2) \"2.2441\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "csharp",
      "code": "GeoRadiusResult[] res4 = db.GeoSearch(\"bikes:rentable\",\n            -122.27652,\n            37.805186,\n            new GeoSearchCircle(5, GeoUnit.Kilometers)\n        );\n\n        foreach (GeoRadiusResult member in res4)\n        {\n            Console.WriteLine($\"Member: '{member.Member}', distance: {member.Distance}, position: {member.Position}\");\n        }\n        // >>> Member: 'station:1', distance: 0.0001, position: -122.27652043104172 37.80518485897756\n        // >>> Member: 'station:2', distance: 0.8047, position: -122.26745992898941 37.80623423353753\n        // >>> Member: 'station:3', distance: 2.6596, position: -122.24698394536972 37.81040384984464",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "go",
      "code": "res4, err := rdb.GeoSearch(ctx, \"bikes:rentable\",\n\t\t&redis.GeoSearchQuery{\n\t\t\tLongitude:  -122.27652,\n\t\t\tLatitude:   37.805186,\n\t\t\tRadius:     5,\n\t\t\tRadiusUnit: \"km\",\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res4) // >>> [station:1 station:2 station:3]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "java",
      "code": "List<GeoRadiusResponse> res4 = jedis.geosearch(\n          \"bikes:rentable\",\n          new GeoCoordinate(-122.27652, 37.805186),\n          5,\n          GeoUnit.KM\n      );\n      List<String> members = res4.stream() //\n          .map(GeoRadiusResponse::getMemberByString) //\n          .collect(Collectors.toList());\n      System.out.println(members); // [station:1, station:2, station:3]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "javascript",
      "code": "const res4 = await client.geoSearch(\n  'bikes:rentable', {\n    longitude: -122.27652,\n    latitude: 37.805186,\n  },\n  { radius: 5,\n    unit: 'km'\n  }\n);\nconsole.log(res4)  // ['station:1', 'station:2', 'station:3']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "python",
      "code": "res4 = r.geosearch(\n    \"bikes:rentable\",\n    longitude=-122.27652,\n    latitude=37.805186,\n    radius=5,\n    unit=\"km\",\n)\nprint(res4)  # >>> ['station:1', 'station:2', 'station:3']",
      "section_id": "examples"
    }
  ]
}
