Share via


st_dwithin function

Applies to: check marked yes Databricks Runtime 17.1 and above

Important

This feature is in Public Preview.

Returns true if the 2D Cartesian distance between the two input geometries is smaller than or equal to the input distance.

Syntax

st_dwithin ( geo1, geo2, d )

Arguments

  • geo1: The first GEOMETRY value.
  • geo2: The second GEOMETRY value.
  • d: The distance threshold.

Returns

A value of type BOOLEAN.

The units of the distance are those of the coordinates of the input geometries.

The function returns NULL if any of the inputs is NULL.

Error conditions

Examples

-- Returns true as the distance between the point and linestring is within the threshold.
> SELECT st_dwithin(st_geomfromtext('POINT Z (0 0 300)'),st_geomfromtext('LINESTRING(-10 10,20 10)'), 10.0)
  true
-- Returns false as the distance between the geometries exceeds the threshold.
> SELECT st_dwithin(st_geomfromtext('POINT(0 0)'),st_geomfromtext('POINT(20 20)'), 10.0)
  false