Skip to main content

ST_DWITHIN

Introduced or updated: v1.2.895

Returns TRUE if two GEOMETRY objects are within the specified Euclidean distance.

This function only supports GEOMETRY values.

Syntax​

ST_DWITHIN(<geometry1>, <geometry2>, <distance>)

Arguments​

ArgumentsDescription
<geometry1>The argument must be an expression of type GEOMETRY.
<geometry2>The argument must be an expression of type GEOMETRY.
<distance>The maximum Euclidean distance as a Float64-compatible value.
note
  • The function reports an error if the two input GEOMETRY objects have different SRIDs.

Return Type​

Boolean.

Examples​

SELECT ST_DWITHIN(TO_GEOMETRY('POINT(0 0)'), TO_GEOMETRY('POINT(1 1)'), 1.5);

╭───────────────────────────────────────────────────────────────────────╮
│ st_dwithin(to_geometry('POINT(0 0)'), to_geometry('POINT(1 1)'), 1.5) │
├───────────────────────────────────────────────────────────────────────┤
│ true │
╰───────────────────────────────────────────────────────────────────────╯
SELECT ST_DWITHIN(TO_GEOMETRY('POINT(0 0)'), TO_GEOMETRY('LINESTRING(2 0, 2 2)'), 1.9);

╭─────────────────────────────────────────────────────────────────────────────────╮
│ st_dwithin(to_geometry('POINT(0 0)'), to_geometry('LINESTRING(2 0, 2 2)'), 1.9) │
├─────────────────────────────────────────────────────────────────────────────────┤
│ false │
╰─────────────────────────────────────────────────────────────────────────────────╯
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today