Amazon Redshift will no longer support the creation of new Python UDFs starting November 1, 2025.
If you would like to use Python UDFs, create the UDFs prior to that date.
Existing Python UDFs will continue to function as normal. For more information, see the
blog post
ST_DWithin
ST_DWithin returns true if the Euclidean distance between the 2D projections of the two input geometry values is not larger than a threshold value.
Syntax
ST_DWithin(geom1, geom2, threshold)
Arguments
- geom1
-
A value of data type
GEOMETRY
or an expression that evaluates to aGEOMETRY
type. - geom2
-
A value of data type
GEOMETRY
or an expression that evaluates to aGEOMETRY
type. - threshold
-
A value of data type
DOUBLE PRECISION
. This value is in the units of the input arguments.
Return type
BOOLEAN
If geom1 or geom2 is null, then null is returned.
If threshold is negative, then an error is returned.
If geom1 and geom2 don't have the same value for the spatial reference system identifier (SRID), 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 distance between two polygons is within five units.
SELECT ST_DWithin(ST_GeomFromText('POLYGON((0 2,1 1,0 -1,0 2))'), ST_GeomFromText('POLYGON((-1 3,2 1,0 -3,-1 3))'),5);
st_dwithin
-----------
true