Skip to content

ST_NumInteriorRings

Returns the number of interior rings (holes) in a polygon geometry or geography.

Usage

integer ST_NumInteriorRings(geom: geometry)
integer ST_NumInteriorRings(geog: geography)

Arguments

  • geog (geography): Input geography
  • geom (geometry): Input geometry

Description

Returns the number of interior rings (holes) in a polygon. For a polygon without holes, returns 0. For multipolygons, returns the number of interior rings in the first polygon. Returns NULL for non-polygon geometry types.

Alias: ST_NumInteriorRing.

Examples

SELECT ST_NumInteriorRings(ST_GeomFromText('POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_numinteriorrings(st_geomfromtext(Utf8("POLYGON ((0 0, 0 10, 10 10, 10 0,  │
│                     0 0), (1 1, 1 2, 2 2, 2 1, 1 1))")))…                    │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                            1 │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_NumInteriorRings(ST_GeogFromWKT('POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_numinteriorrings(st_geogfromwkt(Utf8("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 │
│                      0), (1 1, 1 2, 2 2, 2 1, 1 1))")))…                     │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                            1 │
└──────────────────────────────────────────────────────────────────────────────┘