Skip to content

ST_Within

Returns true if A is completely inside B.

Usage

boolean ST_Within(geomA: geometry, geomB: geometry)

Arguments

  • geomA (geometry): Input geometry
  • geomB (geometry): Input geometry

Description

Returns true if geometry A is completely inside geometry B. This is the inverse of ST_Contains: ST_Within(A, B) is equivalent to ST_Contains(B, A).

Examples

SELECT ST_Within(
    ST_GeomFromWKT('POINT(1 1)'),
    ST_GeomFromWKT('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_within(st_geomfromwkt(Utf8("POINT(1 1)")),st_geomfromwkt(Utf8("POLYGON((0 │
│                          0, 2 0, 2 2, 0 2, 0 0))")))…                        │
╞══════════════════════════════════════════════════════════════════════════════╡
│ true                                                                         │
└──────────────────────────────────────────────────────────────────────────────┘