ST_CONTAINS
Learn how to use the ST_CONTAINS geometry function in PlaidCloud Lakehouse. Returns TRUE if the second GEOMETRY object is completely inside the first...
Returns TRUE if the second GEOMETRY object is completely inside the first GEOMETRY object.
SQL Syntax
ST_CONTAINS(<geometry1>, <geometry2>)
Arguments
| Arguments | Description |
|---|---|
<geometry1> | The argument must be an expression of type GEOMETRY object that is not a GeometryCollection. |
<geometry2> | The argument must be an expression of type GEOMETRY object that is not a GeometryCollection. |
:::note
- The function reports an error if the two input GEOMETRY objects have different SRIDs. :::
Return Type
Boolean.
SQL Examples
SELECT ST_CONTAINS(TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))'), TO_GEOMETRY('POLYGON((-1 0, 0 1, 1 0, -1 0))')) AS contains
┌──────────┐
│ contains │
├──────────┤
│ true │
└──────────┘
SELECT ST_CONTAINS(TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))'), TO_GEOMETRY('LINESTRING(-1 1, 0 2, 1 1)')) AS contains
┌──────────┐
│ contains │
├──────────┤
│ false │
└──────────┘
SELECT ST_CONTAINS(TO_GEOMETRY('POLYGON((-2 0, 0 2, 2 0, -2 0))'), TO_GEOMETRY('LINESTRING(-2 0, 0 0, 0 1)')) AS contains
┌──────────┐
│ contains │
├──────────┤
│ true │
└──────────┘