Skip to content

ST_EQUALS

Returns TRUE if two GEOGRAPHY objects are topologically equal.

Topological equality means that the objects have the same dimension and their point sets occupy the same space, regardless of vertex order.

This function is symmetric, meaning:

  • ST_EQUALS(A, B) = ST_EQUALS(B, A)

Mathematical properties:

  • ST_EQUALS(A, B)A = B
  • ST_EQUALS(A, B)ST_WITHIN(A, B)ST_WITHIN(B, A)

See also:

Syntax

sql
ST_EQUALS(<a>, <b>)

Arguments

  • <a> and <b>: The two GEOGRAPHY objects to compare

Returns

Returns TRUE if the GEOGRAPHY objects are topologically equal, otherwise returns FALSE

Example

sql
SELECT ST_EQUALS('POINT(1 1)'::GEOGRAPHY, 'POINT(1 1)'::GEOGRAPHY);
-- TRUE

SELECT ST_EQUALS('LINESTRING(0 0, 1 1)'::GEOGRAPHY, 'LINESTRING(1 1, 0 0)'::GEOGRAPHY);
-- TRUE (same space, different vertex order)