Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks Runtime 18.2 and above
Important
This feature is in Public Preview.
Returns a point Geometry value with the given coordinates. The function takes 2, 3, or 4 numeric values, representing the (x, y), (x, y, z), or (x, y, z, m) coordinates of the point.
For the corresponding Databricks SQL function, see st_makepoint function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.st_makepoint(*cols)
Parameters
| Parameter | Type | Description |
|---|---|---|
cols |
pyspark.sql.Column or float |
The coordinate values. Must be 2 (x, y), 3 (x, y, z), or 4 (x, y, z, m) arguments. |
Returns
pyspark.sql.Column: A Geometry value, representing a point with the specified coordinates.
The SRID value of the returned geometry is always 0.
The number of input coordinates determines the dimension of the returned point: 2D if you provide only x and y, 3DZ if you also provide z, or 4D if you provide all four coordinates (x, y, z, and m).
The function returns None if any of the inputs is None.
Examples
Creates a 2D point with coordinates (10, 34).
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(10.0, 34.0)], ['x', 'y'])
df.select(dbf.st_astext(dbf.st_makepoint('x', 'y')).alias('result')).collect()
[Row(result='POINT(10 34)')]
Creates a 3DZ point with coordinates (1, 2, 3).
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(1.0, 2.0, 3.0)], ['x', 'y', 'z'])
df.select(dbf.st_astext(dbf.st_makepoint('x', 'y', 'z')).alias('result')).collect()
[Row(result='POINT Z (1 2 3)')]
Creates a 4D point with coordinates (1, 2, 3, 4).
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(1.0, 2.0, 3.0, 4.0)], ['x', 'y', 'z', 'm'])
df.select(dbf.st_astext(dbf.st_makepoint('x', 'y', 'z', 'm')).alias('result')).collect()
[Row(result='POINT ZM (1 2 3 4)')]
The SRID of the returned geometry is always 0.
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(10.0, 34.0)], ['x', 'y'])
df.select(dbf.st_srid(dbf.st_makepoint('x', 'y')).alias('result')).collect()
[Row(result=0)]
The type of the returned geometry is always geometry(0).
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(10.0, 34.0)], ['x', 'y'])
df.select(dbf.typeof(dbf.st_makepoint('x', 'y')).alias('result')).collect()
[Row(result='geometry(0)')]
The function returns None if any of the inputs is None.
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(10.0, None)], ['x', 'y'])
df.select(dbf.st_astext(dbf.st_makepoint('x', 'y')).alias('result')).collect()
[Row(result=None)]