ST_Covers()

Returns 1 when no point of the second geometry lies outside the first geometry.

Syntax

ST_Covers(geom1, geom2)

Aliases: none.

Arguments

geom1 and geom2 are GEOMETRY values.

Return Value

Returns BOOL.

Usage Notes

  • A geometry can cover another geometry on its boundary; this differs from strict containment.

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

Examples

DROP DATABASE IF EXISTS geo_covers_demo;
CREATE DATABASE geo_covers_demo;
USE geo_covers_demo;

SELECT ST_Covers(ST_GeomFromText('POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))'), ST_GeomFromText('POINT(0 2)')) AS covers_boundary_point;

DROP DATABASE geo_covers_demo;

See Also

ST_CoveredBy(), ST_Contains().