Share via


st_numpoints

Applies to: check marked yes Databricks Runtime 18.1 and above

Important

This feature is in Public Preview.

Returns the number of non-empty points in the input Geography or Geometry value.

The function returns None if the input is None.

For the corresponding Databricks SQL function, see st_numpoints function.

This function is an alias for st_npoints.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.st_numpoints(col=<col>)

Parameters

Parameter Type Description
col pyspark.sql.Column or str A Geography or Geometry value.

Examples

Return the number of points in a non-empty multipoint geometry:

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('MULTIPOINT(10 34,44 57,EMPTY)',)], ['wkt'])
df.select(dbf.st_numpoints(dbf.st_geomfromtext('wkt')).alias('result')).collect()
[Row(result=2)]

Return the number of points in an empty multipoint geometry:

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('MULTIPOINT(EMPTY,EMPTY)',)], ['wkt'])
df.select(dbf.st_numpoints(dbf.st_geomfromtext('wkt')).alias('result')).collect()
[Row(result=0)]

Return the number of points in a non-empty polygon geometry:

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON((0 0,1 0,1 1,0 1,0 0))',)], ['wkt'])
df.select(dbf.st_numpoints(dbf.st_geomfromtext('wkt')).alias('result')).collect()
[Row(result=5)]