ST_Overlaps()

Returns 1 when two same-dimensional geometries partially overlap.

Syntax

ST_Overlaps(geom1, geom2)

Aliases: none.

Arguments

geom1 and geom2 are GEOMETRY values.

Return Value

Returns BOOL.

Usage Notes

  • Use it for partial overlap; complete containment is not an overlap.

  • Both geometries must have the same SRID. Predicates are Cartesian (SRID 0), not geodetic SRID 4326 predicates.

Examples

DROP DATABASE IF EXISTS geo_overlaps_demo;
CREATE DATABASE geo_overlaps_demo;
USE geo_overlaps_demo;

SELECT ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GeomFromText('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))')) AS polygons_overlap;

DROP DATABASE geo_overlaps_demo;

See Also

ST_Intersects(), ST_Equals().