ST_InteriorRingN

更新时间:
复制 MD 格式

Returns the Nth interior ring (hole) of a polygon as a LineString. Ring indexes start at 1.

Syntax

geometry ST_InteriorRingN(geometry aPolygon, integer n);

Parameters

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

Usage notes

  • Returns NULL if aPolygon is not a polygon geometry.

  • Returns NULL if the value of n is invalid.

  • Does not support MultiPolygon geometries. Use ST_Dump to decompose a MultiPolygon into individual polygons first.

  • Supports 3D geometries and preserves Z coordinates.

Example

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)