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 Engine API reference for touches.

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

PythonPythonSQLScala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

from geoanalytics.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
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

Python and SQL functions introduced

1.5.0

Scala function introduced

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

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close