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

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_Equals(A, B)` returns `true` if every point in the set of points that make up *A* is also in *B*, and if every point in the set of points that make up *B* is also in *A*.  The ordering of the points in *A* and *B* may differ, but they must be made up of equivalent sets.

Another way of describing `ST_Equals(A, B)` is that it will return `true` if both `ST_Within(A, B)` and `ST_Within(B, A)` also return `true`.

`ST_Equals` works on the following data types:

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

<Note>
  \`\` will attempt to use any available <InternalLink path="spatial-indexes">spatial index</InternalLink> to speed up its operation.  Use the prefixed variant `_` if you do not want any spatial indexes to be used.
</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, \`\` returns `true` because:

* Every Point in the set of Points that make up Polygon *A* is also in Polygon *B*, and  every Point in the set of Points that make up Polygon *B* is also in Polygon *A*

As mentioned above, the ordering of the points in *A* and *B* does not matter.  Below, there are two triangles with the same vertices, which are ordered differently.  In the screenshot, one triangle is drawn in yellow, and the other blue.  The blue and yellow strokes of the two separate triangles' boundaries are visible. Because the images are overlaid on each other, the yellow and blue combine to make part of the exterior outline of the image a green color.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT st_equals(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((-95.992775 36.153980, -87.906471 43.038902, -75.704722 36.076944, -95.992775 36.153980))'));
```

```
   st_equals
---------------
     true

(1 row)
```

<img src="https://mintcdn.com/cockroachlabs/Y5YL0W_DljpJ5-fX/images/v25.3/geospatial/st_equals_true.png?fit=max&auto=format&n=Y5YL0W_DljpJ5-fX&q=85&s=babf2344c74d3b477120dfe2f334f720" alt="ST_Equals - true" width="1280" height="988" data-path="images/v25.3/geospatial/st_equals_true.png" />

### False

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

* It's obvious that not every Point that makes up the set of Points in Polygon *A* is not also in Polygon *B*.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT st_equals(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_equals
---------------
     false
(1 row)
```

<img src="https://mintcdn.com/cockroachlabs/Y5YL0W_DljpJ5-fX/images/v25.3/geospatial/st_equals_false.png?fit=max&auto=format&n=Y5YL0W_DljpJ5-fX&q=85&s=c337eee06a19312ad98e640aae3b1ca6" alt="ST_Equals - false" width="1280" height="988" data-path="images/v25.3/geospatial/st_equals_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</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_intersects">`ST_Intersects`</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_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>
