Skip to main content

st_dwithin

Preview

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. The units of the distance are those of the coordinates of the input geometries.

For the corresponding Databricks SQL function, see st_dwithin function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.st_dwithin(col1=<col1>, col2=<col2>, col3=<col3>)

Parameters

Parameter

Type

Description

col1

pyspark.sql.Column or str

The first Geometry value.

col2

pyspark.sql.Column or str

The second Geometry value.

col3

pyspark.sql.Column or float

The distance threshold.

Notes

The two geometries are expected to have the same SRID value, otherwise an error is returned.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT(0 0)','LINESTRING(-10 10,20 10)')], ['wkt1', 'wkt2'])
df.select(dbf.st_dwithin(dbf.st_geomfromtext('wkt1'), dbf.st_geomfromtext('wkt2'), 10.0).alias('result')).collect()
Output
[Row(result=True)]