{
  "schema_version": 2,
  "id": "commands/geoadd",
  "title": "GEOADD",
  "url": "https://redis.io/docs/latest/commands/geoadd/",
  "summary": "Adds one or more members to a geospatial index. The key is created if it doesn't exist.",
  "since": "3.2.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:43+01:00",
  "page_type": "content",
  "content_hash": "61f8686377811fd950bb0c2f6fcf8cf41b2f2d5a5457759c47a0551b0db7bf14",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Adds the specified geospatial items (longitude, latitude, name) to the specified key. Data is stored into the key as a sorted set, in a way that makes it possible to query the items with the [`GEOSEARCH`](https://redis.io/docs/latest/commands/geosearch) command.\n\nThe command takes arguments in the standard format x,y so the longitude must be specified before the latitude. There are limits to the coordinates that can be indexed: areas very near to the poles are not indexable.\n\nThe exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following:\n\n* Valid longitudes are from -180 to 180 degrees.\n* Valid latitudes are from -85.05112878 to 85.05112878 degrees.\n\nThe command will report an error when the user attempts to index coordinates outside the specified ranges.\n\n**Note:** there is no **GEODEL** command because you can use [`ZREM`](https://redis.io/docs/latest/commands/zrem) to remove elements. The Geo index structure is just a sorted set."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the geospatial index (a sorted set).\n\n</details>\n\n<details open><summary><code>longitude latitude member [longitude latitude member ...]</code></summary>\n\nOne or more longitude-latitude-member triples to add to the index.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "`NX` and `XX` are mutually exclusive.\n\n<details open><summary><code>NX</code></summary>\n\nDon't update already existing elements. Always add new elements.\n\n</details>\n\n<details open><summary><code>XX</code></summary>\n\nOnly update elements that already exist. Never add elements.\n\n</details>\n\n<details open><summary><code>CH</code></summary>\n\nModify the return value from the number of new elements added, to the total number of elements changed (`CH` is an abbreviation of *changed*). Changed elements are **new elements added** and elements already existing for which **the coordinates was updated**. So elements specified in the command line having the same score as they had in the past are not counted. Note: normally, the return value of `GEOADD` only counts the number of new elements added.\n\n</details>"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "how-it-works",
      "title": "How it works",
      "role": "content",
      "text": "The way the sorted set is populated is using a technique called\n[Geohash](https://en.wikipedia.org/wiki/Geohash). Latitude and Longitude\nbits are interleaved to form a unique 52-bit integer. We know\nthat a sorted set double score can represent a 52-bit integer without losing\nprecision.\n\nThis format allows for bounding box and radius querying by checking the 1+8 areas needed to cover the whole shape and discarding elements outside it. The areas are checked by calculating the range of the box covered, removing enough bits from the less significant part of the sorted set score, and computing the score range to query in the sorted set for each area."
    },
    {
      "id": "what-earth-model-does-it-use",
      "title": "What Earth model does it use?",
      "role": "content",
      "text": "The model assumes that the Earth is a sphere since it uses the Haversine formula to calculate distance. This formula is only an approximation when applied to the Earth, which is not a perfect sphere.\nThe introduced errors are not an issue when used, for example, by social networks and similar applications requiring this type of querying. \nHowever, in the worst case, the error may be up to 0.5%, so you may want to consider other systems for error-critical applications."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> GEOADD Sicily 13.361389 38.115556 \"Palermo\" 15.087269 37.502669 \"Catania\"\n(integer) 2\nredis> GEODIST Sicily Palermo Catania\n\"166274.1516\"\nredis> GEORADIUS Sicily 15 37 100 km\n1) \"Catania\"\nredis> GEORADIUS Sicily 15 37 200 km\n1) \"Palermo\"\n2) \"Catania\""
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): When used without optional arguments, the number of elements added to the sorted set (excluding score updates).  If the CH option is specified, the number of elements that were changed (added or updated).\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): When used without optional arguments, the number of elements added to the sorted set (excluding score updates).  If the CH option is specified, the number of elements that were changed (added or updated)."
    }
  ],
  "examples": []
}
