ST_Touches takes two geometry columns and returns a boolean column. The function returns True
if the first geometry and
the second geometry spatially touch on their boundaries (i.e., their intersection is a single point); otherwise, it returns False
.
Function | Syntax |
---|---|
Python | touches(geometry1, geometry2) |
SQL | ST |
Scala | touches(geometry1, geometry2) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for touches.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
from geoanalytics_fabric.sql import functions as ST
data = [
("POLYGON ((0 0, 0 10, 10 10, 10 0))", "LINESTRING (2 2, 10 10, 20 20)" ),
("POLYGON ((0 0, 0 10, 10 10, 10 0))", "LINESTRING (0 10, 5 15, 10 20)")
]
df = spark.createDataFrame(data, ["poly_wkt", "line_wkt"])\
.withColumn("polygon", ST.poly_from_text("poly_wkt"))\
.withColumn("linestring", ST.line_from_text("line_wkt"))\
.withColumn("touches", ST.touches("polygon", "linestring"))\
.drop("poly_wkt", "line_wkt")
df.show(truncate=False)
Result
+-----------------------------------------------+-----------------------------------+-------+
|polygon |linestring |touches|
+-----------------------------------------------+-----------------------------------+-------+
|{"rings":[[[0,0],[0,10],[10,10],[10,0],[0,0]]]}|{"paths":[[[2,2],[10,10],[20,20]]]}|false |
|{"rings":[[[0,0],[0,10],[10,10],[10,0],[0,0]]]}|{"paths":[[[0,10],[5,15],[10,20]]]}|true |
+-----------------------------------------------+-----------------------------------+-------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |