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

# ST_Overlaps

Given two shapes *A* and *B*, `ST_Overlaps(A, B)` returns `true` if the following criteria are met:

* The shapes share any of the same space -- that is, if any point in the set that comprises *A* is also a member of the set of points that make up *B*.
* Neither of the shapes is contained by the other, in the [`ST_Contains`](/docs/stable/st_contains) sense.

In other words, `ST_Overlaps` returns `true` if the shapes intersect (in the [`ST_Intersects`](/docs/stable/st_intersects) sense), but neither is contained within the other.

`ST_Overlaps` works on the following spatial data types:

* [`GEOMETRY`](/docs/stable/architecture/glossary#geometry)

> [!NOTE]
>
> \`\` will attempt to use any available [spatial index](/docs/stable/spatial-indexes.md) to speed up its operation.  Use the prefixed variant `_` if you do not want any spatial indexes to be used.

## Examples

> [!NOTE]
>
> The screenshots in these examples were generated using [geojson.io](http://geojson.io), but they are designed to showcase the shapes, not the map.  Representing `GEOMETRY` data in GeoJSON can lead to unexpected results if using geometries with [SRIDs](/docs/stable/architecture/glossary.md#srid) other than 4326 (as shown below).

### True

In this example, \`\` returns `true` because:

* There is a Point in the set that comprises Polygon *A* that is also a member of the set of Points that make up Polygon *B*.
* Neither of the shapes is contained by the other, in the [`ST_Contains`](/docs/stable/st_contains) sense.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT st_overlaps(st_geomfromtext('SRID=4326;POLYGON((-87.906471 43.038902, -95.992775 36.153980, -75.704722 36.076944, -87.906471 43.038902))'), st_geomfromtext('SRID=4326;POLYGON((-84.191605 39.758949, -75.165222 39.952583, -78.878738 42.880230, -84.191605 39.758949))'));
```

```
  st_overlaps
---------------
     true

(1 row)
```

![ST\_Overlaps - true](https://mintcdn.com/cockroachlabs/bBD0UEapbn6fk8Rb/images/common/geospatial/st_overlaps_true.png?fit=max\&auto=format\&n=bBD0UEapbn6fk8Rb\&q=85\&s=a7b6bfc4c6a5c550f8e7fc560d1f1f8b)

### False

In this example, \`\` returns `false` because:

* * There is not any Point in the set that comprises Polygon *A* that is also a member of the set of Points that make up Polygon *B*.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT st_overlaps(st_geomfromtext('SRID=4326;POLYGON((-79.995888 40.440624,-74.666728 40.358244, -76.5 42.443333, -79.995888 40.440624))'), st_geomfromtext('SRID=4326;POLYGON((-79.976111 40.374444, -74.621157 40.323294, -76.609383 39.299236, -79.976111 40.374444))'));
```

```
  st_overlaps
---------------
     false
(1 row)
```

![ST\_Overlaps - false](https://mintcdn.com/cockroachlabs/bBD0UEapbn6fk8Rb/images/common/geospatial/st_overlaps_false.png?fit=max\&auto=format\&n=bBD0UEapbn6fk8Rb\&q=85\&s=a2e7655b534994abd4d464aafd0a2e73)

## See also

* [Spatial and GIS Glossary of Terms](/docs/stable/architecture/glossary.md)
* [Spatial indexes](/docs/stable/spatial-indexes.md)
* [Spatial functions](/docs/stable/functions-and-operators.md#spatial-functions)
* [`ST_Covers`](/docs/stable/st_covers)
* [`ST_CoveredBy`](/docs/stable/st_coveredby)
* [`ST_Contains`](/docs/stable/st_contains)
* [`ST_Within`](/docs/stable/st_within)
* [`ST_Intersects`](/docs/stable/st_intersects)
* [`ST_CoveredBy`](/docs/stable/st_coveredby)
* [`ST_Covers`](/docs/stable/st_covers)
* [`ST_Disjoint`](/docs/stable/st_disjoint)
* [`ST_Equals`](/docs/stable/st_equals)
* [`ST_Touches`](/docs/stable/st_touches)
* [`ST_ConvexHull`](/docs/stable/st_convexhull)
* [`ST_Union`](/docs/stable/st_union)
* [Migrate from Shapefiles](/docs/stable/migrate-from-shapefiles.md)
* [Migrate from GeoJSON](/docs/stable/migrate-from-geojson.md)
* [Migrate from GeoPackage](/docs/stable/migrate-from-geopackage.md)
* [Migrate from OpenStreetMap](/docs/stable/migrate-from-openstreetmap.md)
* [Introducing Distributed Spatial Data in CockroachDB](https://www.cockroachlabs.com/blog/spatial-data/) (blog post)
