Skip to content

ST_OVERLAPS

Returns TRUE if two GEOGRAPHY objects "spatially overlap". Two geographies overlap if they have the same dimension, their interiors intersect in that dimension, and each has at least one point inside the other (or equivalently, neither one covers the other). The overlaps relation is symmetric and irreflexive.

In mathematical terms: ST_Overlaps(A, B) ⇔ ( dim(A) = dim(B) = dim( Int(A) ⋂ Int(B) )) ∧ (A ⋂ B ≠ A) ∧ (A ⋂ B ≠ B)

See also:

Syntax

sql
ST_OVERLAPS(<a>, <b>)

Arguments

  • <a> and <b>: Two GEOGRAPHY objects to check for overlap

Returns

Returns TRUE if the geographies overlap, FALSE otherwise.

Example

sql
SELECT ST_OVERLAPS('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'::GEOGRAPHY,
                   'POLYGON((0.5 0.5, 1.5 0.5, 1.5 1.5, 0.5 1.5, 0.5 0.5))'::GEOGRAPHY);
-- TRUE