st_interiorringn function
Applies to: Databricks SQL
Databricks Runtime 17.3 and above
Preview
This feature is in Public Preview.
note
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Returns the n-th interior ring of the input polygon as a linestring.
Syntax
st_interiorringn ( geoExpr, indexExpr )
Arguments
geoExpr: AGEOGRAPHYorGEOMETRYvalue.indexExpr: AnINTEGERvalue representing the 1-based position of the interior ring in the polygon.
Returns
The interior ring of the polygon at the 1-based index indexExpr as a closed linestring. The output value has the same data type and SRID as geoExpr.
Notes
The function returns NULL if the input is NULL.
Error conditions
- If
geoExpris not a polygon, the function returns ST_INVALID_ARGUMENT.INVALID_TYPE. - If
indexExpris invalid (less than 1 or greater than theST_NumInteriorRings(geoExpr)), the function returns ST_INVALID_ARGUMENT.INVALID_INDEX_VALUE.
Examples
SQL
-- Example taking a 2D polygon GEOMETRY with three interior rings.
> SELECT ST_AsEWKT(ST_InteriorRingN(ST_GeomFromText('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))', 3857), 3));
SRID=3857;LINESTRING(3 6,4 11,2 10,3 6)
-- Example taking a 3DM polygon GEOGRAPHY with two interior rings.
> SELECT ST_AsEWKT(ST_InteriorRingN(ST_GeogFromText('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))'), 2));
SRID=4326;LINESTRING M (1 4 111,7 5 222,6 8 333,1 4 444)
-- Example taking a 4D polygon GEOMETRY with one interior ring.
> SELECT ST_AsEWKT(ST_InteriorRingN(ST_GeomFromText('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))'), 1));
LINESTRING ZM (3 12 111 -11,9 7 222 -22,5 13 333 -33,3 12 444 -44)