Categories:

Geospatial Functions

ST_DISJOINT

Returns TRUE if the two objects are disjoint (i.e. do not share any portion of space). ST_DISJOINT is equivalent to NOT ST_INTERSECTS(expr1, expr2).

See also:

ST_INTERSECTS

Syntax

ST_DISJOINT( <geography_expression_1> , <geography_expression_2> )

Arguments

geography_expression_1

A GEOGRAPHY object.

geography_expression_2

A GEOGRAPHY object.

Returns

BOOLEAN.

Examples

The following examples use the ST_DISJOINT function to determine if two geospatial objects are disjoint:

-- These two polygons are disjoint and do not intersect.
SELECT ST_DISJOINT(
    TO_GEOGRAPHY('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'),
    TO_GEOGRAPHY('POLYGON((3 3, 5 3, 5 5, 3 5, 3 3))')
    );
+---------------------------------------------------------+
| ST_DISJOINT(                                            |
|     TO_GEOGRAPHY('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'), |
|     TO_GEOGRAPHY('POLYGON((3 3, 5 3, 5 5, 3 5, 3 3))')  |
|     )                                                   |
|---------------------------------------------------------|
| True                                                    |
+---------------------------------------------------------+
-- These two polygons intersect and are not disjoint.
SELECT ST_DISJOINT(
    TO_GEOGRAPHY('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'),
    TO_GEOGRAPHY('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))')
    );
+---------------------------------------------------------+
| ST_DISJOINT(                                            |
|     TO_GEOGRAPHY('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'), |
|     TO_GEOGRAPHY('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))')  |
|     )                                                   |
|---------------------------------------------------------|
| False                                                   |
+---------------------------------------------------------+