Name

ST_InteriorRingN — —Returns the Nth interior ring for a Polygon as a LineString.

Synopsis

geometry ST_InteriorRingN(bytea Polygon, integer n);

Alias

InteriorRingN

Description

Returns the Nth interior ring for a Polygon as a LineString. It also supports MultiIPolygons.

N index starts at 1. If N is less than one or greater than the cardinality of the Interior Rings attribute, then the function returns Null. Also returns Null, if the incoming geometry is not a Polygon or a MultiPolygon.

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
2.1.10.17.2.15.17.2.13.28.2.6 , 8.3.5

Examples

SELECT ST_AsEWKT(ST_InteriorRingN(ST_GeomFromText('POLYGON ((20 20, 50 20, 50 50, 20 50, 20 20), 
  (30 40, 30 30, 40 30, 40 40, 30 40),(22 25, 22 22, 25 22, 25 25, 22 25))'),1));
--Result
LINESTRING (30 40, 30 30, 40 30, 40 40, 30 40)

SELECT ST_AsEWKT(ST_InteriorRingN(ST_GeomFromText('POLYGON ((20 20, 50 20, 50 50, 20 50, 20 20), 
  (30 40, 30 30, 40 30, 40 40, 30 40),(22 25, 22 22, 25 22, 25 25, 22 25))'),2));
--Result
LINESTRING (22 25, 22 22, 25 22, 25 25, 22 25)

SELECT ST_AsEWKT(ST_InteriorRingN(ST_GeomFromText('
MULTIPOLYGON (((0 0, 0 150, 150 150, 150 0, 0 0),(52 56, 52 95, 86 95, 86 56, 52 56)), 
  ((350 0, 230 0, 230 120, 350 120, 350 0),(298 53, 250 100, 300 100, 298 53, 298 53)))
'),2));
--Result
LINESTRING (298 53, 250 100, 300 100, 298 53, 298 53)

Related functions

ST_NRings,ST_NumInteriorRing