PostGISGeometry Accessors

ST_NumInteriorRing

What is ST_NumInteriorRing?

ST_NumInteriorRing is a PostGIS function alias (note the singular form) that returns the number of interior rings in a POLYGON. It is functionally identical to ST_NumInteriorRings and exists for SQL/MM-compatibility naming.

SQL
ST_NumInteriorRing(geometry polygon)integer

Returns NULL for non-polygon input.

When would you use ST_NumInteriorRing?

Use ST_NumInteriorRing when matching the SQL/MM spelling exactly — for example in code that mirrors a formal schema definition. Functionally, the plural ST_NumInteriorRings is more common in PostGIS documentation and community examples:

SQL
1SELECT id, ST_NumInteriorRing(geom) AS holes
2FROM regions
3WHERE ST_NumInteriorRing(geom) > 0;

Prefer ST_NumInteriorRings in new code unless you specifically need the SQL/MM form.

FAQs

Is ST_NumInteriorRing the same as ST_NumInteriorRings?

Yes, both return the count of interior rings of a POLYGON. Choose whichever matches your code-style conventions.

Does ST_NumInteriorRing work on MultiPolygon?

No — returns NULL. Unpack the multi with ST_Dump first.

Why do two names exist?

Historic SQL/MM spec versus PostGIS native naming. Both are kept for compatibility.

Which spelling should I use in new code?

ST_NumInteriorRings (plural) is more broadly used. Either is fine — pick one and stick with it.