This topic describes the ST_Equals function. This function checks whether two geometry objects are spatially equal. If the two geometry objects are spatially equal, this function returns True. Otherwise, this function returns False.

Syntax

boolean  ST_Equals(geometry  a , geometry  b);

Parameters

Parameter Description
a The first geometry object that you want to specify.
b The second geometry object that you want to specify.

Description

  • If both ST_Within(A,B) and ST_Within(B,A) return True, Geometry Object A and Geometry Object B are spatially equal. Geometry Object A and Geometry Object B may have their points arranged in different orders, but they have the same spatial structure.

    You can use the ST_OrderingEquals function to check whether Geometry Object A and Geometry Object B have their points arranged in the same order.

  • If one of the geometry objects that you specify is invalid, this function returns False unless the geometry objects are binarily equal.
  • This function does not support GeometryCollection objects.

Examples

  • The following example shows how two geometry objects are spatially equal even if their points arranged in different orders:
    SELECT ST_Equals('LINESTRING(0 1,2 3)'::geometry,'LINESTRING(2 3,0 1)'::geometry);
     st_equals
    -----------
     t
    (1 row)
                        
  • The following example shows how two geometry objects are identical if they are spatially equal:
    SELECT ST_Equals('LINESTRING(0 1,0 3)'::geometry,'LINESTRING(0 1,0 2,0 3)'::geometry);
     st_equals
    -----------
     t
    (1 row)