Skip to main content

ST_Disjoint

Tests whether two geometries have no points in common.

Syntax​

ST_Disjoint(geometry_a, geometry_b)

Parameters​

ParameterTypeDescription
geometry_aGeometryFirst geometry
geometry_bGeometrySecond geometry

Returns​

TypeDescription
BooleanTrue if geometries are disjoint, false otherwise

Examples​

Separate Polygons​

SELECT ST_Disjoint(
ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
ST_GeomFromText('POLYGON((2 2, 3 2, 3 3, 2 3, 2 2))')
);
-- Returns: true

Point Outside Polygon​

SELECT ST_Disjoint(
ST_Point(10, 10),
ST_GeomFromText('POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))')
);
-- Returns: true

Find Non-overlapping Features​

SELECT a.id, b.id
FROM layer_a a, layer_b b
WHERE ST_Disjoint(a.geom, b.geom);

Notes​

  • ST_Disjoint is the exact opposite of ST_Intersects
  • NOT ST_Intersects(a, b) is equivalent to ST_Disjoint(a, b)
  • Returns true if geometries don't share any points
  • Useful for exclusion queries

See Also​