All Products
Search
Document Center

PolarDB:ST_InteriorRingN

Last Updated:Mar 28, 2026

Returns the Nth interior ring of a Polygon as a LineString. Rings are numbered starting from 1.

Syntax

geometry ST_InteriorRingN(geometry aPolygon, integer n)

Parameters

ParameterDescription
aPolygonThe input Polygon geometry.
nThe 1-based index of the interior ring to return.

Usage notes

  • Returns NULL if the input geometry is not a Polygon or if n is out of range.

  • Does not support MultiPolygon geometries. To use this function with a MultiPolygon, first call ST_Dump to decompose it into individual Polygon geometries.

  • Supports 3D geometries and preserves z coordinates.

Examples

SELECT ST_AsText(ST_InteriorRingN('POLYGON((1 0,3 0,0 3,1 0),(1 0,2 0, 0 2,1 0))'::geometry, 1));

Output:

          st_astext
-----------------------------
 LINESTRING(1 0,2 0,0 2,1 0)
(1 row)