st_numpoints
Applies to: Databricks Runtime 18.1 and above
Preview
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
Python
from pyspark.databricks.sql import functions as dbf
dbf.st_numpoints(col=<col>)
Parameters
Examples
Return the number of points in a non-empty multipoint geometry:
Python
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()
Output
[Row(result=2)]
Return the number of points in an empty multipoint geometry:
Python
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()
Output
[Row(result=0)]
Return the number of points in a non-empty polygon geometry:
Python
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()
Output
[Row(result=5)]