ST_Contains

Contains

ST_Contains takes two geometry columns and returns a boolean column. The result is True if the geometry in the first column completely contains the second; otherwise, it is False.

If the two geometry columns are in different spatial references, the function will automatically transform the second geometry into the spatial reference of the first.

FunctionSyntax
Pythoncontains(geometry1, geometry2)
SQLST_Contains(geometry1, geometry2)
Scalacontains(geometry1, geometry2)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for contains.

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
from geoanalytics_fabric.sql import functions as ST, Polygon, Point

data = [
    (Polygon([[[0,0],[10,10],[20,0]]]), Point(5,2)),
    (Polygon([[[0,0],[10,10],[20,0]]]), Point(20,20)),
]

df = spark.createDataFrame(data, ["polygon", "point"])

df.select(ST.contains("polygon", "point").alias("contains")).show()
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
+--------+
|contains|
+--------+
|    true|
|   false|
+--------+

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.