How the ST_Equals Geometry Checker works, and what it assumes

ST_Equals(A, B) is true when the two geometries contain exactly the same points. It compares space, not text: the order the vertices are listed in, the vertex a ring starts at, the direction it runs and extra vertices along a straight edge make no difference. The DE-9IM pattern is T*F**FFF*, which says that neither geometry has any part in the other's exterior.

That makes it the right test for "has this shape changed?", where comparing WKT strings would report a difference for a geometry that was merely rewritten by another program. PostGIS has ST_OrderingEquals for the stricter, vertex-by-vertex comparison.

Two empty geometries are equal in PostGIS, and here, although their DE-9IM matrix on its own would not say so; the page states when that rule has been applied. Elevations are ignored, because the comparison is two-dimensional.

Where this comes up in GIS work

  • Checking whether a geometry changed between two versions of a dataset, ignoring harmless reordering.
  • Confirming that a round trip through another format or system kept the shape intact.
  • Finding duplicate features whose coordinates are written differently.

A worked example

The same square, written from a different corner, in the opposite direction, with an extra vertex half-way up one side:

A: POLYGON ((0 0, 6 0, 6 6, 0 6, 0 0))
B: POLYGON ((6 6, 0 6, 0 3, 0 0, 6 0, 6 6))

ST_Equals(A, B) = true
DE-9IM matrix: 2FFF1FFF2

The texts differ in every position, and an exact vertex-by-vertex comparison says they are different geometries. Lines behave the same way: LINESTRING (0 0, 10 0) equals LINESTRING (10 0, 5 0, 0 0).

Using the ST_Equals Geometry Checker

  1. Paste the first geometry into Geometry A, or select Load example.
  2. Paste the geometry to compare into Geometry B.
  3. Select Check ST_Equals, or press Ctrl + Enter (Cmd + Enter on a Mac).
  4. Read the verdict; if they differ, the matrix shows whether one extends beyond the other.

When the output looks wrong

The WKT text differs but ST_Equals is true
That is the point of it. ST_Equals compares the space the geometries cover, so a different starting vertex, the opposite direction or an extra vertex on a straight edge make no difference. For an exact vertex-by-vertex match, PostGIS has ST_OrderingEquals.
The shapes look identical but ST_Equals is false
Somewhere the coordinates differ, perhaps only in the sixth decimal place after a round trip through another system. The matrix shows which part lies outside the other. Rounding both to the same precision before comparing usually settles it.
A polygon and its outline are not equal
They are different dimensions: the polygon is an area and its outline is a line, so they cannot cover the same space.

Questions about the ST_Equals Geometry Checker

What is the difference between ST_Equals and comparing the text?

ST_Equals is topological: it is true when the two geometries contain exactly the same points, which is the DE-9IM pattern T*F**FFF*. Two texts can differ in vertex order, direction or redundant vertices and still describe equal geometries.

Are two empty geometries equal?

PostGIS treats two empty geometries as equal, and so does this tool. The DE-9IM matrix of two empties would not say so on its own, which the page notes.

Does ST_Equals compare Z values?

No. Spatial relationships are two-dimensional in PostGIS and here: elevations are ignored.

Is my data uploaded?

No. The comparison runs in your browser.