ST_DISJOINT scalar function
The ST_DISJOINT function takes two geometry objects as input and returns the integer 1 if the specified geometries do not intersect. If the geometries do intersect, then the integer 0 (zero) is returned.
ST_DISJOINT returns the exact opposite result of ST_INTERSECTS.
If geometry1 or geometry2 is null, the result is the null value. If geometry1 or geometry2 is empty, 1 is returned.
- geometry1
- A value of type ST_GEOMETRY that represents the geometry that is tested to be disjoint with geometry2.
- geometry2
- A value of type ST_GEOMETRY that represents the geometry that is tested to be disjoint with geometry1.
The result of the function is INTEGER.
Notes
Two geometries are disjoint if all of the following conditions are true:
- the interior of geometry1 does not intersect the interior of geometry2.
- the interior of geometry1 does not intersect the boundary of geometry2.
- the boundary of geometry1 does not intersect the interior of geometry2.
- the boundaries of geometry1 and geometry2 do not intersect.
Example
Determine if a polygon is disjoint from other polygons.
CREATE TABLE sample_polygons (polygon_id INTEGER, geometry QSYS2.ST_POLYGON);
INSERT INTO sample_polygons VALUES
(10, QSYS2.ST_POLYGON('polygon((30 30, 30 50, 50 50, 50 30, 30 30))')),
(20, QSYS2.ST_POLYGON('polygon((40 40, 40 60, 60 60, 60 40, 40 40))'));
CREATE VARIABLE my_polygon QSYS2.ST_POLYGON;
SET my_polygon = QSYS2.ST_POLYGON('polygon((20 30, 30 30, 30 40, 20 40, 20 30))');
SELECT polygon_id, QSYS2.ST_DISJOINT(my_polygon, geometry) AS disjoint
FROM sample_polygons;
Results:
POLYGON_ID DISJOINT
----------- ---------
10 0
20 1