ST_NUMINTERIORRINGS()

All functions > GEOSPATIAL > ST_NUMINTERIORRINGS()

Returns the number of interior rings (holes) in a Polygon.

Signatures

Number of interior rings

Returns: Number of holes

ST_NUMINTERIORRINGS(polygon: GEOM_POLYGON) → BIGINT
sql
ParameterTypeRequiredDescription
polygonGEOM_POLYGONYesA Polygon geometry

Signature notes:

  • Returns 0 for a polygon with no holes
  • Input must be a Polygon; other sub kinds return NULL
  • GEOMETRY only; not supported on BigQuery
  • On Trino: transpiled to ST_NumInteriorRing (no trailing 's')
  • Returns NULL if the input is NULL

Examples

FeatureQL
SELECT
    -- Polygon with one hole
    f1 := ST_NUMINTERIORRINGS(
        ST_GEOMFROMTEXT(
            'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 4 2, 4 4, 2 4, 2 2))'
        )
    ),
    -- Polygon without holes
    f2 := ST_NUMINTERIORRINGS(
        ST_GEOMFROMTEXT('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')
    )
;
Result
f1 BIGINTf2 BIGINT
10

Last update at: 2026/06/20 10:08:10