ST_Intersection takes two geometry columns and returns a geometry column. The output column contains the
intersection of two input geometry records. You can optionally specify a string value that determines the geometry type of the
result. The string can be one of: 'point'
, 'multipoint'
, 'linestring'
, or 'polygon'
. If no intersection type is specified,
the function will return the same geometry type as the input geometry with the lowest dimension. For example, if you
calculate the intersection of a polygon and a linestring the function will return a linestring.
The function will return an empty geometry if the two input geometries do not intersect or there is no intersection that matches the specified intersect type. If the intersection is a single point, the geometry type of the result column will be a multipoint.
To find the intersection of all records in a column or a group use ST_Aggr_Intersection.
Function | Syntax |
---|---|
Python | intersection(geometry1, geometry2, intersect |
SQL | ST |
Scala | intersection(geometry1, geometry2, intersect |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for intersection.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
from geoanalytics_fabric.sql import functions as ST, Linestring, Polygon
data = [
(Polygon([[[0,0],[10,10],[20,0]]]), Linestring([[[5,2],[20,20]]])),
(Polygon([[[0,0],[10,10],[20,0]]]), Linestring([[[30,40],[32,43]]])),
]
df = spark.createDataFrame(data, ["polygon", "linestring"])
df.select(ST.intersection("polygon", "linestring").alias("intersection")).show(truncate=False)
+----------------------------------------------------------+
|intersection |
+----------------------------------------------------------+
|{"paths":[[[5,2],[10.909090909090908,9.090909090909092]]]}|
|{"paths":[]} |
+----------------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |