Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
4. How ST_Equals works
Relationships Between Geometries
ST_Distance and ST_Dwithin
Spatial joins practice


Nicely done! As we've already mentioned, ST_Equals checks whether two geometries represent the same location or space. ST_Equals ignores the order of vertices in a polygon, the starting point of a polygon, and even additional vertices that do not change its shape. Look at the image below:


ST_Equals will consider Figure 1, Figure 2, Figure 3, and Figure 4 to be equal, even though their representations are certainly different. Take a look at the following query:

FROM sf_hotels sh
JOIN sf_sights ss
  ON ST_Equals(sh.boundaries, 

As you can see, we passed in the ST_Reverse function as one of the arguments to ST_Equals. The ST_Reverse function returns a geometry with the vertex order reversed. So, if we had the linestring ABC, the ST_Reverse function would return the linestring CBA.

In accordance with our earlier explanation, even though we reversed the vertex order of one of its arguments, the ST_Equals function still returned TRUE and gave us the same result.


Click the Run and Check Code button and note that both ST_Equals usages return the same result.