ST_INTERIORRINGN()

All functions > GEOSPATIAL > ST_INTERIORRINGN()

Returns the Nth interior ring (hole) of a Polygon as a LineString (1-indexed).

Signatures

Interior ring N

Returns: The Nth hole as a closed LineString

ST_INTERIORRINGN(polygon: GEOM_POLYGON, n: INT) → GEOM_LINESTRING
sql
ParameterTypeRequiredDescription
polygonGEOM_POLYGONYesA Polygon geometry
nINTYes1-based ring index

Signature notes:

  • Index is 1-based
  • Out of range index returns NULL
  • Input must be a Polygon; other sub kinds return NULL
  • GEOMETRY only; not supported on BigQuery
  • Returns NULL if any input is NULL

Examples

FeatureQL
SELECT
    f1 := ST_ASTEXT(ST_INTERIORRINGN(ST_GEOMFROMTEXT('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 4 2, 4 4, 2 4, 2 2))'), 1)) -- First hole of a polygon with one hole
;
Result
f1 VARCHAR
LINESTRING (2 2, 4 2, 4 4, 2 4, 2 2)

Last update at: 2026/05/26 17:22:09