> ## 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.

# ST_Intersects

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>;
};

Given two shapes *A* and *B*, `ST_Intersects(A, B)` returns `true` if 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*.

`ST_Intersects` works on the following data types:

* <InternalLink path="architecture/glossary#geometry">`GEOMETRY`</InternalLink>
* <InternalLink path="architecture/glossary#geography">`GEOGRAPHY`</InternalLink>

<Note>
  `ST_Intersects` will attempt to use any available <InternalLink path="spatial-indexes">spatial index</InternalLink> to speed up its
  operation. Use the prefixed variant `_ST_Intersects` if you do not want any spatial indexes to be used.
</Note>

<Note>
  This function is the inverse of <InternalLink path="st_disjoint">`ST_Disjoint`</InternalLink>.
</Note>

## 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 <InternalLink path="architecture/glossary#srid">SRIDs</InternalLink> other than 4326 (as shown below).
</Note>

### True

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

* The shapes share some of the same space -- that is, there are Points in the set that comprises Polygon *A* that are also members of Polygon *B*.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT st_intersects(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))'));
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
 st_intersects
---------------
     true

(1 row)
```

<img src="https://mintcdn.com/cockroachlabs/_ajVjtIOzaJKY_2M/images/v25.4/geospatial/st_intersects_true.png?fit=max&auto=format&n=_ajVjtIOzaJKY_2M&q=85&s=88534b95383fde8d4c370af32d65d2a3" alt="ST_Intersects - true" width="1280" height="988" data-path="images/v25.4/geospatial/st_intersects_true.png" />

### False

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

* The shapes do not share any of the same space -- that is, there are no Points in the set that comprises Polygon *A* that are also members of Polygon *B*.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT st_intersects(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((-79.995888 40.440624,-74.666728 40.358244, -76.5 42.443333, -79.995888 40.440624))'));
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
 st_intersects
---------------
     false
(1 row)
```

<img src="https://mintcdn.com/cockroachlabs/_ajVjtIOzaJKY_2M/images/v25.4/geospatial/st_intersects_false.png?fit=max&auto=format&n=_ajVjtIOzaJKY_2M&q=85&s=b4ae3b5334a8798c1faf4a20c7ae1037" alt="ST_Intersects - false" width="1280" height="988" data-path="images/v25.4/geospatial/st_intersects_false.png" />

## See also

* <InternalLink path="export-spatial-data">Export Spatial Data</InternalLink>
* <InternalLink path="spatial-tutorial">Spatial tutorial</InternalLink>
* <InternalLink path="architecture/glossary">Spatial and GIS Glossary of Terms</InternalLink>
* <InternalLink path="spatial-indexes">Spatial indexes</InternalLink>
* <InternalLink path="functions-and-operators#spatial-functions">Spatial functions</InternalLink>
* <InternalLink path="st_covers">`ST_Covers`</InternalLink>
* <InternalLink path="st_coveredby">`ST_CoveredBy`</InternalLink>
* <InternalLink path="st_contains">`ST_Contains`</InternalLink>
* <InternalLink path="st_within">`ST_Within`</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_overlaps">`ST_Overlaps`</InternalLink>
* <InternalLink path="st_touches">`ST_Touches`</InternalLink>
* <InternalLink path="st_convexhull">`ST_ConvexHull`</InternalLink>
* <InternalLink path="st_union">`ST_Union`</InternalLink>
* <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>
* [Introducing Distributed Spatial Data in CockroachDB](https://www.cockroachlabs.com/blog/spatial-data) (blog post)
* <InternalLink path="geoserver">Using GeoServer with CockroachDB</InternalLink>
