Skip to main content

st_numinteriorrings

Preview

Support for GEOGRAPHY values is in Public Preview. Support for GEOMETRY values is generally available.

Returns the number of interior rings of the input polygon.

For the corresponding Databricks SQL function, see st_numinteriorrings function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.st_numinteriorrings(col=<col>)

Parameters

Parameter

Type

Description

col

pyspark.sql.Column or str

A Geography or Geometry value representing a polygon.

Notes

The function returns None if the input is None.

The input value is expected to represent a polygon, otherwise an error is returned.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON EMPTY',)], ['wkt'])
df.select(dbf.st_numinteriorrings(dbf.st_geomfromtext('wkt', 4326)).alias('result')).collect()
Output
[Row(result=0)]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON Z ((0 0 6,1 0 6,1 1 8,0 1 6,0 0 6))',)], ['wkt'])
df.select(dbf.st_numinteriorrings(dbf.st_geogfromtext('wkt')).alias('result')).collect()
Output
[Row(result=0)]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON ZM ((0 0 111 -11,10 0 222 -22,0 10 333 -33,0 0 444 -44),(1 1 555 -55,4 1 666 -66,1 4 777 -77,1 1 888 -88))',)], ['wkt'])
df.select(dbf.st_numinteriorrings(dbf.st_geomfromtext('wkt', 4326)).alias('result')).collect()
Output
[Row(result=1)]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON M ((0 0 1,10 0 2,0 10 3,0 0 1),(1 1 2,2 1 3,1 2 4,1 1 2),(3 3 3,3 2 4,2 3 5,3 3 3))',)], ['wkt'])
df.select(dbf.st_numinteriorrings(dbf.st_geogfromtext('wkt')).alias('result')).collect()
Output
[Row(result=2)]