This topic describes the ST_CoveredBy function. This function checks whether no point of the first geometry object or geography object that you specify lies outside the second geometry object or geography object that you specify. If no point of the first object lies outside the second object, this function returns True. Otherwise, this function returns False.

Syntax

boolean  ST_CoveredBy(geometry  geomA , geometry  geomB);
boolean  ST_CoveredBy(geography  geogA , geography  geogB);

Parameters

Parameter Description
geomA The first geometry object that you want to specify.
geomB The second geometry object that you want to specify.
geogA The first geography object that you want to specify.
geogB The second geography object that you want to specify.

Description

  • This function does not support GeometryCollection objects.
  • Do not specify invalid geometry objects. If you specify invalid geometry objects, this function returns an unexpected result.
  • This function generates a bounding box, which allows you to use the indexes that are available on the geometry objects that you specify. If you do not want to use indexes, we recommend that you use the _ST_CoveredBy function.

Examples

Compare two geometry objects by using the default parameter settings.
SELECT ST_Covers(g1,g2), ST_CoveredBy(g2,g1) FROM (SELECT 'POLYGON((0 0,1 1,1 0,0 0))'::geometry as g1,
                                                   		 		'LINESTRING(0 0,1 1)'::geometry as g2) as test;
 st_covers | st_coveredby
-----------+--------------
 t         | t
(1 row)