ST_Z

ST_Z can work as a getter or a setter, depending on the inputs.

Getter: ST_Z takes a point column and returns a double column containing the z-coordinates of the input points. If a point does not have a z-coordinate the function returns NaN.

Setter: ST_Z takes a point column and a numeric value or column and returns a point column containing the input points with the z-coordinates set to the numeric value.

FunctionSyntax
Pythonz(point, new_value=None)
SQLST_Z(point, new_value)
Scalaz(point, value)

For more details, go to the GeoAnalytics Engine API reference for z.

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

Getter

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
from geoanalytics.sql import functions as ST

data = [
    ('{"x": -0.126,"y": 51.504,"z": 11253}',),
    ('{"x": -0.126,"y": 51.504}',)
]

df = spark.createDataFrame(data, ["esri_json"]) \
    .withColumn("point", ST.point_from_esri_json("esri_json"))

df.select(ST.z("point").alias("get_z")).show()
Result-as-getter
Use dark colors for code blocksCopy
1
2
3
4
5
6
+-------+
|  get_z|
+-------+
|11253.0|
|    NaN|
+-------+

Setter

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
from geoanalytics.sql import functions as ST

data = [
    ('{"x": -0.126,"y": 51.504,"z": 11253}', 12000),
    ('{"x": -0.126,"y": 51.504}', 10000)
]

df = spark.createDataFrame(data, ["esri_json", "new_value"]) \
    .withColumn("point", ST.point_from_esri_json("esri_json"))

df.select(ST.z("point", "new_value").alias("set_z")).show(truncate=False)
Result-as-setter
Use dark colors for code blocksCopy
1
2
3
4
5
6
+---------------------------------+
|set_z                            |
+---------------------------------+
|{"x":-0.126,"y":51.504,"z":12000}|
|{"x":-0.126,"y":51.504,"z":10000}|
+---------------------------------+

Version table

ReleaseNotes

1.0.0

Python and SQL functions introduced

1.5.0

Scala function introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.