Appearance
ST_CONTAINS
Returns TRUE
if one GEOGRAPHY
object contains another. A GEOGRAPHY
A contains B if and only if:
- All points of B lie inside A (either within the interior or on the boundary)
- The interiors of A and B share at least one point in common
This function has the following properties:
- Reflexive: Every
GEOGRAPHY
object contains itself - Antisymmetric: If
ST_CONTAINS(A, B) = TRUE
andST_CONTAINS(B, A) = TRUE
, then A and B are topologically equal - Converse of
ST_WITHIN
:ST_CONTAINS(A, B) = ST_WITHIN(B, A)
See also:
Syntax
sql
ST_CONTAINS(<a>, <b>)
Arguments
<a>
and<b>
: TheGEOGRAPHY
objects to check for containment relationship
Returns
Returns TRUE
if <a>
contains <b>
, FALSE
otherwise.
Example
sql
SELECT ST_CONTAINS('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'::GEOGRAPHY, 'POINT(1 1)'::GEOGRAPHY);
-- TRUE
SELECT ST_CONTAINS('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'::GEOGRAPHY, 'POINT(3 3)'::GEOGRAPHY);
-- FALSE