All Products
Search
Document Center

PolarDB:ST_Within

Last Updated:Mar 28, 2026

Returns true if a raster object is completely within another raster object or a geometry object. Both objects must share the same spatial reference system.

Syntax

bool ST_Within(raster rast1, raster rast2);
bool ST_Within(raster rast, geometry geom);
bool ST_Within(geometry geom, raster rast);

Parameters

ParameterDescription
rast1The raster object to test (the candidate that may be within rast2).
rast2The raster object that may contain rast1.
rastThe raster object.
geomThe geometry object.

Examples

The following example checks which rasters in tbl_a are completely within the rasters in tbl_b.

SELECT a.id FROM tbl_a a, tbl_b b WHERE ST_Within(a.rast, b.rast);

Output:

 id
----
  1
(1 row)