ST_NRings¶
Returns the total number of rings in a geometry or geography (both exterior and interior rings).
Usage¶
integer ST_NRings(geom: geometry)
integer ST_NRings(geog: geography)
Arguments¶
- geog (geography): Input geography
- geom (geometry): Input geometry
Description¶
Returns the total number of rings (exterior and interior) in a polygon or multipolygon. For a simple polygon, this is 1 plus the number of holes. For a multipolygon, it is the sum of all rings in all polygons. Returns 0 for non-polygon geometry types.
Examples¶
SELECT ST_NRings(ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))'));
┌─────────────────────────────────────────────────────────────────────────┐
│ st_nrings(st_geomfromtext(Utf8("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"))) │
│ int32 │
╞═════════════════════════════════════════════════════════════════════════╡
│ 1 │
└─────────────────────────────────────────────────────────────────────────┘
SELECT ST_NRings(ST_GeogFromWKT('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))'));
┌────────────────────────────────────────────────────────────────────────┐
│ st_nrings(st_geogfromwkt(Utf8("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"))) │
│ int32 │
╞════════════════════════════════════════════════════════════════════════╡
│ 1 │
└────────────────────────────────────────────────────────────────────────┘