Skip to main content

st_makepoint

Applies to: check marked yes Databricks Runtime 18.2 and above

Preview

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

Python
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).

Python
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()
Output
[Row(result='POINT(10 34)')]

Creates a 3DZ point with coordinates (1, 2, 3).

Python
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()
Output
[Row(result='POINT Z (1 2 3)')]

Creates a 4D point with coordinates (1, 2, 3, 4).

Python
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()
Output
[Row(result='POINT ZM (1 2 3 4)')]

The SRID of the returned geometry is always 0.

Python
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()
Output
[Row(result=0)]

The type of the returned geometry is always geometry(0).

Python
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()
Output
[Row(result='geometry(0)')]

The function returns None if any of the inputs is None.

Python
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()
Output
[Row(result=None)]