ST_X can work as a getter or a setter, depending on the inputs.
Getter: ST_X takes a point column and returns a double column containing the x-coordinate of the input points.
Setter: ST_X takes a point column and a numeric value or column and returns a point column containing the input points with the x-coordinates set to the numeric value.
Function | Syntax |
---|---|
Python | x(point, new |
SQL | ST |
Scala | x(point, value) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for x.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
Getter
from geoanalytics_fabric.sql import functions as ST, Point
df = spark.createDataFrame([(Point(-178, -17),)], ["point"])
df.select(ST.x("point").alias("get_x")).show()
+------+
| get_x|
+------+
|-178.0|
+------+
Setter
from geoanalytics_fabric.sql import functions as ST, Point
df = spark.createDataFrame([(Point(-178, -17),)], ["point"])
df.select(ST.x("point",-150).alias("set_x")).show()
+------------------+
| set_x|
+------------------+
|{"x":-150,"y":-17}|
+------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |