ST_Crosses

Crosses

ST_Crosses takes two geometry columns and returns a boolean column. The function returns True if the two geometries cross; otherwise, it returns False. Two geometries cross when their intersection is not empty and is not equal to either of the geometries. The intersection must also have a dimensionality less than the maximum dimension of the two input geometries.

This function is only relevant for the following combinations of geometries:

  • multipoint/linestring
  • multipoint/polygon
  • linestring/polygon
  • linestring/multipoint
  • linestring/linestring
  • polygon/multipoint
  • polygon/linestring

For all other combinations the function will always return 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
Pythoncrosses(geometry1, geometry2)
SQLST_Crosses(geometry1, geometry2)
Scalacrosses(geometry1, geometry2)

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

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, Linestring, Polygon

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

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

df.select(ST.crosses("polygon", "linestring").alias("crosses")).show()
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
+-------+
|crosses|
+-------+
|   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.