ST_M can work as a getter or a setter, depending on the inputs.
Getter: ST_M takes a point column and returns a double column containing the m-values of the input points. If a
point does not have an m-value the function returns Na
.
Setter: ST_M takes a point column and a numeric value and returns a point column containing the input points with the m-values set to the numeric value.
Function | Syntax |
---|---|
Python | m(point, new |
SQL | ST |
Scala | m(point, value) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for m.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
Getter
from geoanalytics_fabric.sql import functions as ST
data = [
('{"x": -0.126,"y": 51.504,"m": 187.73}',),
('{"x": -0.126,"y": 51.504}',)
]
df = spark.createDataFrame(data, ["esri_json"]) \
.withColumn("point", ST.point_from_esri_json("esri_json"))
df.select(ST.m("point").alias("get_m")).show()
+------+
| get_m|
+------+
|187.73|
| NaN|
+------+
Setter
from geoanalytics_fabric.sql import functions as ST
data = [
('{"x": -0.126,"y": 51.504,"m": 187.73}', 43.26),
('{"x": -0.126,"y": 51.504}', 97.22)
]
df = spark.createDataFrame(data, ["esri_json", "new_value"]) \
.withColumn("point", ST.point_from_esri_json("esri_json"))
df.select(ST.m("point", "new_value").alias("set_m")).show(truncate=False)
+---------------------------------+
|set_m |
+---------------------------------+
|{"x":-0.126,"y":51.504,"m":43.26}|
|{"x":-0.126,"y":51.504,"m":97.22}|
+---------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |