ST_Within

Determine whether one geometry is contained completely within another geometry, that is, whether their DE-9IM intersection matrix is T*F**F***.

ST_Within is the reverse of ST_Contains.

Syntax

ST_Within(geo1, geo2);
geo1
The first input geometry.

Type: ST_GEOMETRY(ANY)

geo2
The second input geometry.

Type: ST_GEOMETRY(ANY)

Returns

A value of type BOOL that is TRUE if the first geometry is completely contained within the second geometry; otherwise FALSE.

Examples

SELECT inza..ST_Within(inza..ST_WKTToSQL('POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))', 27700),
   inza..ST_WKTToSQL('POLYGON ((0 0, 110 0, 110 110, 0 110, 0 0))', 27700));
   
ST_WITHIN
-----------
t
(1 row)