ST_Touches

Touches

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.

FunctionSyntax
Pythontouches(geometry1, geometry2)
SQLST_Touches(geometry1, geometry2)
Scalatouches(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

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
Use dark colors for code blocksCopy
1
2
3
4
5
6
+-----------------------------------------------+-----------------------------------+-------+
|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

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.