{
  "schema_version": 2,
  "id": "develop/ai/search-and-query/advanced-concepts/geo",
  "title": "Geospatial",
  "url": "https://redis.io/docs/latest/develop/ai/search-and-query/advanced-concepts/geo/",
  "summary": "Learn how to use geospatial fields and perform geospatial queries in Redis",
  "aliases": [
    "/develop/interact/search-and-query/advanced-concepts/geo",
    "/develop/ai/search-and-query/indexing/geo"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-29T16:29:37+01:00",
  "page_type": "content",
  "content_hash": "5157e7bc5ec5a0b09d21034884e04412ad15dd7513fba4d0b8e2cd37754ea1d9",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Redis Search supports geospatial data. This feature\nlets you store geographical locations and geometric shapes\nin the fields of JSON objects.\n\n> [!NOTE]\n> Take care not to confuse the geospatial indexing\n> features in Redis Search with the\n> [Geospatial data type](https://redis.io/docs/latest/develop/data-types/geospatial)\n> that Redis also supports. Although there are some similarities between\n> these two features, the data type is intended for simpler use\n> cases and doesn't have the range of format options and queries\n> available in Redis Search.\n\nYou can index these fields and use queries to find the objects\nby their location or the relationship of their shape to other shapes.\nFor example, if you add the locations of a set of shops, you can\nfind all the shops within 5km of a user's position or determine\nwhich ones are within the boundary of a particular town.\n\nRedis uses coordinate points to represent geospatial locations.\nYou can store individual points but you can also\nuse a set of points to define a polygon shape (the shape of a\ntown, for example). You can query several types of interactions\nbetween points and shapes, such as whether a point lies within\na shape or whether two shapes overlap.\n\nRedis can interpret coordinates either as geographical longitude\nand latitude or as Cartesian coordinates on a flat plane.\nGeographical coordinates are ideal for large real-world locations\nand areas (such as towns and countries). Cartesian coordinates\nare more suitable for smaller areas (such as rooms in a building)\nor for games, simulations, and other artificial scenarios."
    },
    {
      "id": "storing-geospatial-data",
      "title": "Storing geospatial data",
      "role": "content",
      "text": "Redis supports two different\n[schema types](https://redis.io/docs/latest/develop/ai/search-and-query/indexing/field-and-type-options)\nfor geospatial data:\n\n-   [`GEO`](#geo): This uses a simple format where individual geospatial\n    points are specified as numeric longitude-latitude pairs.\n    \n-   [`GEOSHAPE`](#geoshape): [Redis Open Source](https://redis.io/docs/latest/operate/oss_and_stack) also\n    supports `GEOSHAPE` indexing in v7.2 and later.\n    This uses a subset of the \n    [Well-Known Text (WKT)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry)\n    format to specify both points and polygons using either geographical\n    coordinates or Cartesian coordinates. A\n    `GEOSHAPE` field supports more advanced queries than `GEO`,\n    such as checking if one shape overlaps or contains another.\n\nThe sections below describe these schema types in more detail."
    },
    {
      "id": "geo",
      "title": "`GEO`",
      "role": "content",
      "text": "A `GEO` index lets you represent geospatial data either as\na string containing a longitude-latitude pair (for example,\n\"-104.991531, 39.742043\") or as a JSON array of these\nstrings. Note that the longitude value comes first in the\nstring.\n\nFor example, you could index the `location` fields of the\nthe [JSON](https://redis.io/docs/latest/develop/data-types/json) objects\nshown below as `GEO`:\n\n[code example]\n\n`GEO` fields allow only basic point and radius queries.\nFor example, the query below finds products within a 100 mile radius of Colorado Springs\n(Longitude=-104.800644, Latitude=38.846127).\n\n[code example]\n\nNote that `GEO` fields are stored in C `double` type variables and they are limited to approximately 15 to 17 digits of precision.\n\nSee [Geospatial queries](https://redis.io/docs/latest/develop/ai/search-and-query/query/geo-spatial)\nfor more information about the available query options and see\n[Geospatial indexing](https://redis.io/docs/latest/develop/ai/search-and-query/indexing/geoindex)\nfor examples of indexing `GEO` fields."
    },
    {
      "id": "geoshape",
      "title": "`GEOSHAPE`",
      "role": "content",
      "text": "Fields indexed as `GEOSHAPE` support the `POINT` and `POLYGON` primitives from the\n[Well-Known Text](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry)\nrepresentation of geometry. The `POINT` primitive defines a single point\nin a similar way to a `GEO` field.\nThe `geom` field of the example JSON object shown below specifies a point\n(in Cartesian coordinates, using the standard x,y order):\n\n[code example]\n\nThe `POLYGON` primitive can approximate the outline of any shape using a\nsequence of points. Specify the coordinates of the corners in the order they\noccur around the shape (either clockwise or counter-clockwise) and ensure the\nshape is \"closed\" by making the final coordinate exactly the same as the first.\n\nNote that `POLYGON` requires double parentheses around the coordinate list.\nThis is because you can specify additional shapes as a comma-separated list\nthat define \"holes\" within the enclosing polygon. The holes must have the opposite\nwinding order to the outer polygon (so, if the outer polygon uses a clockwise winding\norder, the holes must use counter-clockwise).\nThe `geom` field of the example JSON object shown below specifies a\nsquare using Cartesian coordinates in a clockwise winding order:\n\n[code example]\n\nThe following examples define one `POINT` and three `POLYGON` primitives,\nwhich are shown in the image below:\n\n[code example]\n\n![](https://redis.io/docs/latest/images/dev/rqe/geoshapes.jpg)\n\nYou can run various types of queries against a geospatial index. For\nexample, the query below returns one primitive that lies within the boundary\nof the green square (from the example above) but omits the square itself:\n\n[code example]\n\nThere are four query operations that you can use with `GEOSHAPE` fields:\n\n-   `WITHIN`: Find points or shapes that lie entirely within an\n    enclosing shape that you specify in the query.\n-   `CONTAINS`: Find shapes that completely contain the specified point\n    or shape.\n-   `INTERSECTS`: Find shapes whose boundary overlaps another specified\n    shape.\n-   `DISJOINT`: Find shapes whose boundary does not overlap another specified\n    shape.\n\nSee\n[Geospatial queries](https://redis.io/docs/latest/develop/ai/search-and-query/query/geo-spatial)\nfor more information about these query types and see\n[Geospatial indexing](https://redis.io/docs/latest/develop/ai/search-and-query/indexing/geoindex)\nfor examples of indexing `GEOSHAPE` fields."
    },
    {
      "id": "limitations-of-geographical-coordinates",
      "title": "Limitations of geographical coordinates",
      "role": "limits",
      "text": "Planet Earth is actually shaped more like an\n[ellipsoid](https://en.wikipedia.org/wiki/Earth_ellipsoid) than a perfect sphere.\nThe spherical coordinate system used by Redis Search is a close\napproximation to the shape of the Earth but not exact. For most practical\nuses of geospatial queries, the approximation works very well, but you\nshouldn't rely on it if you need very precise location data (for example, to track\nthe GPS locations of boats in an emergency response system)."
    }
  ],
  "examples": [
    {
      "id": "geo-ex0",
      "language": "json",
      "code": "{\n    \"description\": \"Navy Blue Slippers\",\n    \"price\": 45.99,\n    \"city\": \"Denver\",\n    \"location\": \"-104.991531, 39.742043\"\n}\n\n{\n    \"description\": \"Bright Red Boots\",\n    \"price\": 185.75,\n    \"city\": \"Various\",\n    \"location\": [\n        \"-104.991531, 39.742043\",\n        \"-105.0618814,40.5150098\"\n    ]\n}",
      "section_id": "geo"
    },
    {
      "id": "geo-ex1",
      "language": "bash",
      "code": "FT.SEARCH productidx '@location:[-104.800644 38.846127 100 mi]'",
      "section_id": "geo"
    },
    {
      "id": "geoshape-ex0",
      "language": "json",
      "code": "{\n    \"name\": \"Purple Point\",\n    \"geom\": \"POINT (2 2)\"\n}",
      "section_id": "geoshape"
    },
    {
      "id": "geoshape-ex1",
      "language": "json",
      "code": "{\n    \"name\": \"Green Square\",\n    \"geom\": \"POLYGON ((1 1, 1 3, 3 3, 3 1, 1 1))\"\n}",
      "section_id": "geoshape"
    },
    {
      "id": "geoshape-ex2",
      "language": "plaintext",
      "code": "POINT (2 2)\nPOLYGON ((1 1, 1 3, 3 3, 3 1, 1 1))\nPOLYGON ((2 2.5, 2 3.5, 3.5 3.5, 3.5 2.5, 2 2.5))\nPOLYGON ((3.5 1, 3.75 2, 4 1, 3.5 1))",
      "section_id": "geoshape"
    },
    {
      "id": "geoshape-ex3",
      "language": "bash",
      "code": "> FT.SEARCH geomidx \"(-@name:(Green Square) @geom:[WITHIN $qshape])\" PARAMS 2 qshape \"POLYGON ((1 1, 1 3, 3 3, 3 1, 1 1))\" RETURN 1 name DIALECT 2\n\n1) (integer) 1\n2) \"shape:4\"\n3) 1) \"name\"\n   2) \"[\\\"Purple Point\\\"]\"",
      "section_id": "geoshape"
    }
  ]
}
