> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Spatial Data Overview

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

CockroachDB supports efficiently storing and querying spatial data.

See the links below for more information about how to use CockroachDB for spatial use cases.

## Getting Started

* <InternalLink path="install-cockroachdb">Install CockroachDB</InternalLink>
* <InternalLink path="spatial-tutorial">Spatial tutorial</InternalLink>

## Migrating spatial data into and out of CockroachDB

* <InternalLink path="migrate-from-shapefiles">Migrate from Shapefiles</InternalLink>
* <InternalLink path="migrate-from-geojson">Migrate from GeoJSON</InternalLink>
* <InternalLink path="migrate-from-geopackage">Migrate from GeoPackage</InternalLink>
* <InternalLink path="migrate-from-openstreetmap">Migrate from OpenStreetMap</InternalLink>
* <InternalLink path="export-spatial-data">Export Spatial Data</InternalLink>

## Reference

* <InternalLink path="spatial-indexes">Spatial indexes</InternalLink>
* <InternalLink path="architecture/glossary">Spatial and GIS Glossary of Terms</InternalLink>
* Refer to <InternalLink path="spatial-data-overview#known-limitations">Known Limitations</InternalLink>
* <InternalLink path="functions-and-operators#spatial-functions">Spatial functions</InternalLink>
* <InternalLink path="query-spatial-data#compatibility">Client library compatibility</InternalLink>

### Spatial objects

* <InternalLink path="point">POINT</InternalLink>
* <InternalLink path="linestring">LINESTRING</InternalLink>
* <InternalLink path="polygon">POLYGON</InternalLink>
* <InternalLink path="multipoint">MULTIPOINT</InternalLink>
* <InternalLink path="multilinestring">MULTILINESTRING</InternalLink>
* <InternalLink path="multipolygon">MULTIPOLYGON</InternalLink>
* <InternalLink path="geometrycollection">GEOMETRYCOLLECTION</InternalLink>

### Data representations

* <InternalLink path="well-known-text">Well known text</InternalLink>
* <InternalLink path="well-known-binary">Well known binary</InternalLink>
* <InternalLink path="geojson">GeoJSON</InternalLink>
* <InternalLink path="srid-4326">SRID 4326 - longitude and latitude</InternalLink>

### Spatial functions

In addition to the <InternalLink path="functions-and-operators#spatial-functions">generated reference documentation for spatial functions</InternalLink>, we have written additional documentation for the following functions, including examples:

* <InternalLink path="st_contains">`ST_Contains`</InternalLink>
* <InternalLink path="st_convexhull">`ST_ConvexHull`</InternalLink>
* <InternalLink path="st_coveredby">`ST_CoveredBy`</InternalLink>
* <InternalLink path="st_covers">`ST_Covers`</InternalLink>
* <InternalLink path="st_disjoint">`ST_Disjoint`</InternalLink>
* <InternalLink path="st_equals">`ST_Equals`</InternalLink>
* <InternalLink path="st_intersects">`ST_Intersects`</InternalLink>
* <InternalLink path="st_overlaps">`ST_Overlaps`</InternalLink>
* <InternalLink path="st_touches">`ST_Touches`</InternalLink>
* <InternalLink path="st_union">`ST_Union`</InternalLink>
* <InternalLink path="st_within">`ST_Within`</InternalLink>

## Known limitations

* Not all [PostGIS spatial functions](https://postgis.net/docs/reference) are supported.
* The `AddGeometryColumn` <InternalLink path="functions-and-operators#spatial-functions">spatial function</InternalLink> only allows constant arguments.
* The `AddGeometryColumn` spatial function only allows the `true` value for its `use_typmod` parameter.
* CockroachDB does not support the `@` operator. Instead of using `@` in spatial expressions, we recommend using the inverse, with `~`. For example, instead of `a @ b`, use `b ~ a`.
* CockroachDB does not yet support <InternalLink path="insert">`INSERT`</InternalLink> s into the <InternalLink path="architecture/glossary#spatial-system-tables">`spatial_ref_sys` table</InternalLink>. This limitation also blocks the [`ogr2ogr -f PostgreSQL` file conversion command](https://gdal.org/programs/ogr2ogr#cmdoption-ogr2ogr-f).
* CockroachDB does not yet support [k-nearest neighbors](https://wikipedia.org/wiki/K-nearest_neighbors_algorithm).
* CockroachDB does not support using <InternalLink path="sql-name-resolution#how-name-resolution-works">schema name prefixes</InternalLink> to refer to <InternalLink path="data-types">data types</InternalLink> with type modifiers (e.g., `public.geometry(linestring, 4326)` ). Instead, use fully-unqualified names to refer to data types with type modifiers (e.g., `geometry(linestring,4326)` ).
* Defining a custom SRID by inserting rows into <InternalLink path="architecture/glossary#spatial_ref_sys">`spatial_ref_sys`</InternalLink> is not currently supported.
* Clusters that mix `s390x` with other CPU architectures are unsupported for geospatial workloads. Due to differences in how trigonometric functions are computed on `s390x` systems, geospatial queries in heterogeneous clusters with `s390x` are likely to get incorrect results. This can include taking a backup on one architecture and restoring it on another.
* <InternalLink path="spatial-data-overview">Spatial features</InternalLink> are disabled on ARM Macs due to an issue with macOS code signing for the [GEOS](https://libgeos.org/) libraries. Users needing spatial features on an ARM Mac may instead [use Rosetta](https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta) to <InternalLink path="install-cockroachdb">run the Intel binary</InternalLink> or use the <InternalLink path="install-cockroachdb#use-docker">Docker image</InternalLink> distribution.

## See also

* [Introducing Distributed Spatial Data in CockroachDB](https://www.cockroachlabs.com/blog/spatial-data) (blog post)
* <InternalLink path="geoserver">Using GeoServer with CockroachDB</InternalLink>
