Amazon Redshift will no longer support the creation of new Python UDFs starting Patch 198.
Existing Python UDFs will continue to function until June 30, 2026. For more information, see the
blog post
ST_Within
ST_Within returns true if the 2D projection of the first input geometry is within the 2D projection of the second input geometry.
For example, geometry A is within geometry B if every point
in A is a point in B and their interiors have nonempty
intersection.
ST_Within(A, B) is equivalent to ST_Contains(B, A).
Syntax
ST_Within(geom1, geom2)
Arguments
- geom1
-
A value of data type
GEOMETRYor an expression that evaluates to aGEOMETRYtype. This value is compared with geom2 to determine if it is within geom2. - geom2
-
A value of data type
GEOMETRYor an expression that evaluates to aGEOMETRYtype.
Return type
BOOLEAN
If geom1 or geom2 is null, then null is returned.
If geom1 and geom2 don't have the same spatial reference system identifier (SRID) value, then an error is returned.
If geom1 or geom2 is a geometry collection, then an error is returned.
Examples
The following SQL checks if the first polygon is within the second polygon.
SELECT ST_Within(ST_GeomFromText('POLYGON((0 2,1 1,0 -1,0 2))'), ST_GeomFromText('POLYGON((-1 3,2 1,0 -3,-1 3))'));
st_within
-----------
true