st_interiorringn
Preview
This feature is in Public Preview.
Returns the n-th interior ring of the input polygon as a closed linestring.
For the corresponding Databricks SQL function, see st_interiorringn function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.st_interiorringn(col1=<col1>, col2=<col2>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| |
|
| An integer value representing the 1-based position of the interior ring in the polygon. |
Notes
The output value has the same data type and SRID as the input polygon. The function returns a closed linestring.
The function returns None if any of the inputs 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((0 1,10 5,4 20,0 1),(3 12,9 7,5 13,3 12),(1 4,7 5,6 8,1 4),(3 6,4 11,2 10,3 6))',)], ['wkt'])
df.select(dbf.st_asewkt(dbf.st_interiorringn(dbf.st_geomfromtext('wkt', 3857), 3)).alias('result')).collect()
Output
[Row(result='SRID=3857;LINESTRING(3 6,4 11,2 10,3 6)')]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON M ((0 1 111,10 5 222,4 20 333,0 1 444),(3 12 111,9 7 222,5 13 333,3 12 444),(1 4 111,7 5 222,6 8 333,1 4 444))',)], ['wkt'])
df.select(dbf.st_asewkt(dbf.st_interiorringn(dbf.st_geogfromtext('wkt'), 2)).alias('result')).collect()
Output
[Row(result='SRID=4326;LINESTRING M (1 4 111,7 5 222,6 8 333,1 4 444)')]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON ZM ((0 1 111 -11,10 5 222 -22,4 20 333 -33,0 1 444 -44),(3 12 111 -11,9 7 222 -22,5 13 333 -33,3 12 444 -44))',)], ['wkt'])
df.select(dbf.st_asewkt(dbf.st_interiorringn(dbf.st_geomfromtext('wkt'), 1)).alias('result')).collect()
Output
[Row(result='LINESTRING ZM (3 12 111 -11,9 7 222 -22,5 13 333 -33,3 12 444 -44)')]