Name

ST_NRings — Returns the number of rings of a Polygon or a MultiPolygon.

Synopsis

integer ST_NRings(bytea Geometry);

Alias

NRings

Description

Returns the number of rings of a Polygon or a MultiPolygon. If the input geometry is different from a Polygon or MultiPolygon, returns null.

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
----

Examples

SELECT ST_NRings(geom),ST_NumInteriorRings(geom) FROM (SELECT ST_GeomFromText
('POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0),(2 2, 2 4, 4 4, 4 2, 2 2),(6 6,6 8, 8 8,8 6,6 6))') as geom) as foo;

 st_nrings | st_numinteriorrings
-----------+---------------------
         3 |                   2
(1 row)

Related functions

ST_NumInteriorRing