Skip to main content
Returns the number of rings in a Polygon or MultiPolygon. Contrary to ST_NumInteriorRings, this function also takes into account the number of exterior rings. This function returns 0 for an empty Polygon or MultiPolygon. If the geometry is not a Polygon or MultiPolygon, an IllegalArgument Exception is thrown. ST_NRings

Signatures

ST_NRings(geom: Geometry)

Parameters

geom
Geometry
required
The input geometry.

Return type

An integer value.

Example

Input: POLYGON ((1 0, 1 1, 2 1, 2 0, 1 0))
1
Input: 'MULTIPOLYGON (((1 0, 1 6, 6 6, 6 0, 1 0), (2 1, 2 2, 3 2, 3 1, 2 1)), ((10 0, 10 6, 16 6, 16 0, 10 0), (12 1, 12 2, 13 2, 13 1, 12 1)))'
4
Input: 'POLYGON EMPTY'
0
Input: 'LINESTRING (1 0, 1 1, 2 1)'
Unsupported geometry type: LineString, only Polygon or MultiPolygon geometries are supported.