Skip to content

ST_Contains

Returns true if geomA contains geomB.

Usage

boolean ST_Contains(geomA: geometry, geomB: geometry)
boolean ST_Contains(geogA: geography, geogB: geography)

Arguments

  • geogA (geography): Input geography
  • geogB (geography): Input geography
  • geomA (geometry): Input geometry
  • geomB (geometry): Input geometry

Description

Returns true if no points of B lie outside A and at least one point of B lies inside A.

Examples

SELECT ST_Contains(
    ST_GeomFromText('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'),
    ST_Point(0.25, 0.25)
) AS val;
┌─────────┐
│   val   │
│ boolean │
╞═════════╡
│ true    │
└─────────┘
SELECT ST_Contains(
    ST_GeogFromText('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'),
    ST_GeogPoint(0.25, 0.25)
) AS val;
┌─────────┐
│   val   │
│ boolean │
╞═════════╡
│ true    │
└─────────┘